homeman-deno/routes/admin.tsx

24 lines
544 B
TypeScript
Raw Permalink Normal View History

2024-01-07 02:24:36 -06:00
import { Handlers, PageProps } from '$fresh/server.ts'
import { db } from '@homeman/db.ts'
2024-01-07 02:24:36 -06:00
import { Admin, Props } from '@homeman/islands/Admin.tsx'
export const handler: Handlers = {
async GET(_req, ctx) {
2024-01-16 16:45:51 -06:00
const users = Object.fromEntries((await db.users.findMany({})).map(
(u) => [u.id, u],
))
2024-01-07 02:24:36 -06:00
const todos = await db.todos.findMany({})
return ctx.render({ users, todos })
},
}
export default function Home(
{ data: props }: PageProps<Props>,
) {
return (
<main class='flex flex-col'>
<Admin {...props} />
</main>
)
}