brf/server/routes/api/accounts.ts

27 lines
558 B
TypeScript

import _ from 'lodash'
import * as z from 'zod'
import type { FastifyPluginCallbackZod } from 'fastify-type-provider-zod'
import { AccountSchema } from '../../schemas/db.ts'
const accountRoutes: FastifyPluginCallbackZod = (fastify, _, done) => {
const { db } = fastify
fastify.route({
url: '/',
method: 'GET',
schema: {
response: {
200: z.array(AccountSchema),
},
},
handler() {
return db.selectFrom('account').selectAll().orderBy('number').execute()
},
})
done()
}
export default accountRoutes