You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
620 B

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.crypto_random32();
Bun.write(config.IMAGEDIR + '/' + image_id, file);
return new Response(image_id);
} else if (url.pathname === '/api/ping') {
return new Response('pong');
}
}