This commit is contained in:
kokopi
2026-03-08 19:40:53 +09:00
commit 16bc00632d
67 changed files with 2476 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import fp from 'fastify-plugin'
import type { FastifyPluginAsync } from 'fastify'
import { SQLiteAdapter } from '../adapters/sqlite.ts'
import type { StorageAdapter } from '../types.ts'
declare module 'fastify' {
interface FastifyRequest {
storage: StorageAdapter
}
}
const adapter: StorageAdapter = new SQLiteAdapter()
const plugin: FastifyPluginAsync = async (app) => {
app.decorateRequest('storage', null)
app.addHook('onRequest', async (req) => {
req.storage = adapter
})
}
export const storageMiddleware = fp(plugin)