From 91dcd7fb4787f7eec03dec240fb1293fc1ba045e Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Wed, 13 Mar 2024 07:52:13 -0500 Subject: [PATCH] Add parser options helper for supplying partial options --- src/middleware/jsonBodyParser/jsonBodyParser.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/middleware/jsonBodyParser/jsonBodyParser.ts b/src/middleware/jsonBodyParser/jsonBodyParser.ts index 54a95bf..92d0a39 100644 --- a/src/middleware/jsonBodyParser/jsonBodyParser.ts +++ b/src/middleware/jsonBodyParser/jsonBodyParser.ts @@ -19,6 +19,17 @@ export const DefaultJsonBodyParserOptions: OptionsJson = { type: DefaultJsonBodyParserOptionsTypes, } +/** + * Gets the default JSON Body Parser options merged with the supplied options + * with the supplied options taking precedence + * @param options The options to override the default JSON Body Parser options with + * @returns The combined JSON Body Parser options with the supplied values taking + * precedence over the default + */ +export const getJsonBodyParserOptions = (options: Partial): OptionsJson => { + return { ...DefaultJsonBodyParserOptions, ...options } +} + /** * Get a JSON Body Parser connect middleware handler * @param options The options for the JSON Body Parser