import type { HandlerFunc, Context } from "https://deno.land/x/abc@master/mod.ts"; import db, {loginData} from "../db/user.ts"; export const index: HandlerFunc = async (c: Context) => c.params.name; export const register: HandlerFunc = async (c: Context) => { const { username, email, password } = await c.body(); const success = await db.createUser(email, username, password); // TODO: Send email return {success}; }; export const login: HandlerFunc = async (c: Context) => { const { username, password } = await c.body(); const data: loginData = await db.login(username, password); if (data.success) { c.setCookie({ name: "uid", value: data.uid!.toString(), }); c.setCookie({ name: "verification", value: data.verification!, }) } return {"success": data.success}; }