24 lines
548 B
TypeScript
24 lines
548 B
TypeScript
import { Handlers, PageProps } from '$fresh/server.ts'
|
|
import { db } from '@homeman/models.ts'
|
|
import { Admin, Props } from '@homeman/islands/Admin.tsx'
|
|
|
|
export const handler: Handlers = {
|
|
async GET(_req, ctx) {
|
|
const users = Object.fromEntries((await db.users.findMany({})).map(
|
|
(u) => [u.id, u],
|
|
))
|
|
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>
|
|
)
|
|
}
|