mirror of
https://github.com/4ev-link/4ev.link.git
synced 2026-01-13 16:18:05 +00:00
14 lines
548 B
JavaScript
14 lines
548 B
JavaScript
export async function onRequestPost({ request, env }) {
|
|
try {
|
|
const { admin_pass } = await request.json();
|
|
if (admin_pass !== env.ADMIN_PASS) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const schema = `CREATE TABLE IF NOT EXISTS users (username TEXT PRIMARY KEY, pass_hash TEXT, custom_slugs TEXT);`;
|
|
await env.D1_EV.exec(schema);
|
|
|
|
return new Response("Schema v1 created successfully (if it did not exist).");
|
|
} catch (e) {
|
|
return new Response(e.message, { status: 500 });
|
|
}
|
|
}
|