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); console.log(url.pathname); 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(); await Bun.write(config.IMAGEDIR + '/' + image_id, file); storage.put_image(image_id, desk_id); return new Response(image_id); } }