feat: setup/login/logout/me auth routes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import Fastify, { FastifyInstance } from 'fastify'
|
||||
import Database from 'better-sqlite3'
|
||||
import cookie from '@fastify/cookie'
|
||||
import type { Config } from './config.js'
|
||||
import { registerAuthRoutes } from './routes/authRoutes.js'
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
@@ -8,6 +10,9 @@ declare module 'fastify' {
|
||||
config: Config
|
||||
fetchImpl: typeof fetch
|
||||
}
|
||||
interface FastifyRequest {
|
||||
user?: import('./auth.js').UserRow
|
||||
}
|
||||
}
|
||||
|
||||
export interface AppOptions {
|
||||
@@ -21,6 +26,10 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
|
||||
app.decorate('db', opts.db)
|
||||
app.decorate('config', opts.config)
|
||||
app.decorate('fetchImpl', opts.fetchImpl ?? fetch)
|
||||
|
||||
await app.register(cookie)
|
||||
await registerAuthRoutes(app)
|
||||
|
||||
app.get('/api/health', async () => ({ ok: true }))
|
||||
return app
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user