diff --git a/package.json b/package.json index cc29d96..a5e8fca 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "homepage": "https://github.com/Eomm/fastify-raw-body#readme", "devDependencies": { "@types/node": "^20.1.0", - "fastify": "^4.10.0", + "fastify": "^4.19.0", "standard": "^17.0.0", "tap": "^16.2.0", "tsd": "^0.28.0" diff --git a/plugin.d.ts b/plugin.d.ts index 9807aa6..604ad23 100644 --- a/plugin.d.ts +++ b/plugin.d.ts @@ -4,6 +4,10 @@ declare module 'fastify' { interface FastifyRequest { rawBody?: string | Buffer } + + interface FastifyContextConfig { + rawBody?: boolean + } } type FastifyRawBody = FastifyPluginCallback diff --git a/test/types/types.test.ts b/test/types/types.test.ts index ab2628d..9691150 100644 --- a/test/types/types.test.ts +++ b/test/types/types.test.ts @@ -1,3 +1,5 @@ +import { expectType } from 'tsd' + import fastifyFactory from 'fastify' import rawBodyPlugin, { RawBodyPluginOptions } from '../../plugin' @@ -15,3 +17,8 @@ fastify.register(rawBodyPlugin, options2) fastify.register(rawBodyPlugin, options3) fastify.register(rawBodyPlugin, options4) fastify.register(rawBodyPlugin, options5) + +fastify.get('/', { config: { rawBody: true } }, (request, reply) => { + expectType(request.routeConfig.rawBody) + return "rawBody enabled" +})