Skip to content

Commit

Permalink
feat: add ability to pass body-parser options
Browse files Browse the repository at this point in the history
feature: add ability to pass body-parser options
  • Loading branch information
schickling authored Apr 26, 2018
2 parents 6545533 + c449866 commit 41f5abb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import * as bodyParser from 'body-parser'
import { Request, Response, NextFunction, RequestHandler } from 'express'

export const bodyParserGraphQL: () => RequestHandler = () => (
export interface BodyParserJSONOptions {
limit?: number | string,
inflate?: boolean,
reviver?: any,
strict?: boolean,
type?: string,
verify?: any,
}

export const bodyParserGraphQL: (options?: BodyParserJSONOptions) => RequestHandler = (options?: BodyParserJSONOptions) => (
req: Request,
res: Response,
next: NextFunction
Expand All @@ -15,7 +24,7 @@ export const bodyParserGraphQL: () => RequestHandler = () => (
next()
})
} else {
bodyParser.json()(req, res, next)
bodyParser.json(options)(req, res, next)
}
}

Expand Down

0 comments on commit 41f5abb

Please sign in to comment.