Ethan Niser 2023-09-15 17:45:17 +00:00 committed by GitHub
parent 72f523a885
commit 10a7427d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 16 deletions

@ -0,0 +1,4 @@
function Component({ name }: { name: string }) {
return <p>this is unsafe: {name}</p>;
}

@ -41,8 +41,9 @@ export const authController = new Elysia({
const sessionCookie = auth.createSessionCookie(session); const sessionCookie = auth.createSessionCookie(session);
cookie.sesion?.set(sessionCookie); // cookie.session?.set(sessionCookie);
set.headers["Set-Cookie"] = sessionCookie.serialize();
set.headers["HX-Location"] = "/profile"; set.headers["HX-Location"] = "/profile";
}, },
{ {
@ -87,7 +88,8 @@ export const authController = new Elysia({
}); });
const sessionCookie = auth.createSessionCookie(session); const sessionCookie = auth.createSessionCookie(session);
cookie.sesion?.set(sessionCookie); // cookie.sesion?.set(sessionCookie);
set.headers["Set-Cookie"] = sessionCookie.serialize();
set.headers["HX-Location"] = "/profile"; set.headers["HX-Location"] = "/profile";
}, },
{ {

@ -11,9 +11,7 @@ export const todosController = new Elysia({
}) })
.use(ctx) .use(ctx)
.get("/", async () => { .get("/", async () => {
const now = performance.now();
const data = await db.select().from(todos).limit(10); const data = await db.select().from(todos).limit(10);
console.log("queried in", performance.now() - now);
return <TodoList todos={data} />; return <TodoList todos={data} />;
}) })
.post( .post(
@ -71,14 +69,11 @@ export const todosController = new Elysia({
sub: "Subscribe to Ethan", sub: "Subscribe to Ethan",
}; };
const now = performance.now();
const [newTodo] = await db const [newTodo] = await db
.insert(todos) .insert(todos)
.values({ content: content[body.content] }) .values({ content: content[body.content] })
.returning(); .returning();
console.log("inserted in", performance.now() - now);
if (!newTodo) { if (!newTodo) {
throw new Error("Todo not found"); throw new Error("Todo not found");
} }
@ -88,9 +83,6 @@ export const todosController = new Elysia({
// console.log("total time", performance.now() - now); // console.log("total time", performance.now() - now);
// }); // });
console.log("returning");
console.log("total time", performance.now() - now);
return <TodoItem {...newTodo} />; return <TodoItem {...newTodo} />;
}, },
{ {

@ -8,9 +8,7 @@ export const profile = new Elysia()
const authRequest = auth.handleRequest(request); const authRequest = auth.handleRequest(request);
const session = await authRequest.validate(); const session = await authRequest.validate();
if (session) { return html(
return html(<div>Hello {session.user.email}</div>); session ? <div>Hello {session.user.email}</div> : <div>Not logged in</div>
} else { );
return html(<div>Not logged in</div>);
}
}); });

@ -21,6 +21,6 @@
"types": [ "types": [
"bun-types" // add Bun global "bun-types" // add Bun global
], ],
"plugins": [{ "name": "@kitajs/html/tsp" }] // "plugins": [{ "name": "@kitajs/html/tsp" }]
} }
} }