forked from
samuel.fm/statusphere-react
the statusphere demo reworked into a vite/react app in a monorepo
1import { AppContext } from '#/context'
2import { Server } from '#/lexicons'
3import { statusToStatusView } from '#/lib/hydrate'
4
5export default function (server: Server, ctx: AppContext) {
6 server.xyz.statusphere.getStatuses({
7 handler: async ({ params }) => {
8 // Fetch data stored in our SQLite
9 const statuses = await ctx.db
10 .selectFrom('status')
11 .selectAll()
12 .orderBy('indexedAt', 'desc')
13 .limit(params.limit)
14 .execute()
15
16 return {
17 encoding: 'application/json',
18 body: {
19 statuses: await Promise.all(
20 statuses.map((status) => statusToStatusView(status, ctx)),
21 ),
22 },
23 }
24 },
25 })
26}