Skip to content

Commit 41f5abb

Browse files
authored
feat: add ability to pass body-parser options
feature: add ability to pass body-parser options
2 parents 6545533 + c449866 commit 41f5abb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: src/index.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import * as bodyParser from 'body-parser'
22
import { Request, Response, NextFunction, RequestHandler } from 'express'
33

4-
export const bodyParserGraphQL: () => RequestHandler = () => (
4+
export interface BodyParserJSONOptions {
5+
limit?: number | string,
6+
inflate?: boolean,
7+
reviver?: any,
8+
strict?: boolean,
9+
type?: string,
10+
verify?: any,
11+
}
12+
13+
export const bodyParserGraphQL: (options?: BodyParserJSONOptions) => RequestHandler = (options?: BodyParserJSONOptions) => (
514
req: Request,
615
res: Response,
716
next: NextFunction
@@ -15,7 +24,7 @@ export const bodyParserGraphQL: () => RequestHandler = () => (
1524
next()
1625
})
1726
} else {
18-
bodyParser.json()(req, res, next)
27+
bodyParser.json(options)(req, res, next)
1928
}
2029
}
2130

0 commit comments

Comments
 (0)