Files
XIVPlan-DB/mod.ts
Ean Milligan 90d578e662 db init stuff
2026-04-07 03:47:00 -04:00

28 lines
920 B
TypeScript

import { customAlphabet } from '@nanoid';
import { STATUS_CODE, STATUS_TEXT, StatusCode } from '@std/http';
import config from '~config';
// Using custom alphabet to exclude - and _
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const nanoid = customAlphabet(alphabet, 20);
const genericResponse = (status: StatusCode, customText = '') =>
new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
Deno.serve({ port: config.api.port }, async (req) => {
const [urlPath, tempQ] = req.url.split('?');
const path = (urlPath.split('api/')[1] ?? '').toLowerCase().trim();
console.log(urlPath, path);
if (req.method === 'GET') {
// handle all gets
} else if (path === '/auth') {
return new Response(nanoid());
} else {
// handle auth then all other shiz
}
return genericResponse(STATUS_CODE.NotImplemented);
});