Skip to content

Commit

Permalink
feat: infamous triplet (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm authored Dec 13, 2022
1 parent a87d6bc commit aa75b31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"test": "tap test/**.test.* && tsd"
"test": "tap test/**.test.* && tsd",
"test:types": "tsd"
},
"repository": {
"type": "git",
Expand All @@ -17,6 +18,8 @@
"raw-body",
"body",
"request",
"fastify",
"fastify-plugin",
"fastify-raw-body"
],
"author": "Manuel Spigolon <[email protected]> (https://github.com/Eomm)",
Expand Down
24 changes: 16 additions & 8 deletions plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ declare module 'fastify' {
}
}

export interface RawBodyPluginOptions {
field?: string
global?: boolean
encoding?: string | null | false
runFirst?: boolean
routes?: string[]
type FastifyRawBody = FastifyPluginCallback<fastifyRawBody.RawBodyPluginOptions>

declare namespace fastifyRawBody {
export interface RawBodyPluginOptions {
field?: string
global?: boolean
encoding?: string | null | false
runFirst?: boolean
routes?: string[]
}

export const fastifyRawBody: FastifyRawBody;
export { fastifyRawBody as default };
}

declare const fastifyRawBody: FastifyPluginCallback<RawBodyPluginOptions>
export default fastifyRawBody

declare function fastifyRawBody(...params: Parameters<FastifyRawBody>): ReturnType<FastifyRawBody>
export = fastifyRawBody
6 changes: 5 additions & 1 deletion plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ function rawBody (fastify, opts, next) {
}
}

module.exports = fp(rawBody, {
const plugin = fp(rawBody, {
fastify: '^4.10.x',
name: 'fastify-raw-body'
})

module.exports = plugin
module.exports.default = plugin
module.exports.fastifyRawBody = plugin

0 comments on commit aa75b31

Please sign in to comment.