chore: update gitignore for phase02
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import fp from 'fastify-plugin';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { createDb, type Database } from '@source/database';
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
db: Database;
|
||||
}
|
||||
}
|
||||
|
||||
export default fp(async (app: FastifyInstance) => {
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
if (!databaseUrl) {
|
||||
throw new Error('DATABASE_URL environment variable is required');
|
||||
}
|
||||
|
||||
const db = createDb(databaseUrl);
|
||||
app.decorate('db', db);
|
||||
|
||||
app.log.info('Database connected');
|
||||
});
|
||||
Reference in New Issue
Block a user