HUUUGE dump of code, toast system in a svelte module, new reworked tailwing color palette, WIP cms, WIP API and probably much more that i forgot about.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { fileContents } from '$lib/server/db/schema';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
if (event.params.guid === undefined)
|
||||
return new Response(`Bad request - no guid specified`, { status: 400 });
|
||||
|
||||
const row = await db
|
||||
.select()
|
||||
.from(fileContents)
|
||||
.where(eq(fileContents.guid, event.params.guid))
|
||||
.limit(1);
|
||||
if (!row.length) {
|
||||
return new Response(`File not found`, { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(new Uint8Array(row[0].data), {
|
||||
headers: {
|
||||
'Content-Type': row[0].mimeType || 'application/octet-stream',
|
||||
'Cache-Control': 'public, max-age=86400'
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user