chore: crush git history - reborn from consolidation on 2026-03-10
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import fp from 'fastify-plugin'
|
||||
|
||||
export interface DatabasePluginOptions {
|
||||
url: string
|
||||
}
|
||||
|
||||
export const databasePlugin = fp(async (fastify, opts: DatabasePluginOptions) => {
|
||||
// In a real app, this would connect to PostgreSQL, MongoDB, etc.
|
||||
const db = {
|
||||
users: new Map<string, { id: string; name: string; email: string }>(),
|
||||
url: opts.url,
|
||||
}
|
||||
|
||||
fastify.decorate('db', db)
|
||||
|
||||
fastify.addHook('onClose', async () => {
|
||||
// Cleanup connections
|
||||
})
|
||||
})
|
||||
|
||||
// Type augmentation for Fastify
|
||||
declare module 'fastify' {
|
||||
interface FastifyInstance {
|
||||
db: {
|
||||
users: Map<string, { id: string; name: string; email: string }>
|
||||
url: string
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user