import * as config from './config'; import * as math from './math'; import * as storage from './storage'; export async function route(req) { const url = new URL(req.url); if (url.pathname === '/api/image') { const desk_id = url.searchParams.get('deskId') || '0'; const formdata = await req.formData(); const file = formdata.get('file'); const image_id = math.fast_random32(); Bun.write(config.IMAGEDIR + '/' + image_id, file); return new Response(image_id); } else if (url.pathname === '/api/ping') { return new Response('pong'); } }