around the table

This commit is contained in:
2025-08-21 00:27:58 -04:00
parent 35a5af154f
commit 7d8ac0db76
4 changed files with 54 additions and 20 deletions

View File

@@ -7,17 +7,24 @@ import { liveTable } from "./table";
const api = new Elysia({ prefix: "/api" })
.post("/whoami", async ({ cookie: { token } }) => {
let human;
if (token.value == null) {
const newHuman = await db.human.create({
human = await db.human.create({
data: {},
});
token.set({
value: newHuman.token,
value: human.token,
expires: dayjs().add(1, "year").toDate(),
httpOnly: true,
});
} else {
human = await db.human.findUniqueOrThrow({
where: {
token: token.value,
},
});
}
return token.value;
return human.key;
})
.use(human)
.post(