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:
@@ -2,8 +2,9 @@ import { db } from '$lib/server/db';
|
||||
import { filesystem } from '$lib/server/db/schema';
|
||||
import { MD5 } from '$lib/termos/util/hash';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { RequestEvent } from './$types';
|
||||
|
||||
export async function GET({ request }): Promise<Response> {
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
const row = await db
|
||||
.select({
|
||||
data: filesystem.data,
|
||||
@@ -18,7 +19,7 @@ export async function GET({ request }): Promise<Response> {
|
||||
}
|
||||
|
||||
const { data, checksum } = row[0];
|
||||
const clientETag = request.headers.get('if-none-match');
|
||||
const clientETag = event.request.headers.get('if-none-match');
|
||||
|
||||
if (clientETag === `"${checksum}"`) {
|
||||
return new Response(null, {
|
||||
@@ -37,15 +38,15 @@ export async function GET({ request }): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST({ request }) {
|
||||
const newData = await request.text();
|
||||
export async function POST(event: RequestEvent) {
|
||||
const newData = await event.request.text();
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(newData);
|
||||
JSON.parse(newData);
|
||||
//TODO: Schema validation
|
||||
} catch {
|
||||
//TODO: Change that to a proper http headers error
|
||||
return new Response(null, {
|
||||
return new Response('Invalid JSON', {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user