-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11325 from tolgap/fix/11302-remove-body-parser-ty…
…pes-dep fix(express): remove body-parser types and ship these types our own
- Loading branch information
Showing
6 changed files
with
49 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './nest-express-application.interface'; | ||
export * from './nest-express-body-parser-options.interface'; | ||
export { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface'; | ||
export * from './nest-express-body-parser.interface'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 25 additions & 5 deletions
30
packages/platform-express/interfaces/nest-express-body-parser-options.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
import type { Options } from 'body-parser'; | ||
import type { IncomingMessage } from 'http'; | ||
|
||
export type NestExpressBodyParserOptions<T extends Options = Options> = Omit< | ||
T, | ||
'verify' | ||
>; | ||
/** | ||
* Type alias to keep compatibility with @types/body-parser | ||
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/dcd1673c4fa18a15ea8cd8ff8af7d563bb6dc8e6/types/body-parser/index.d.ts#L48-L66#L48-L66 | ||
* @publicApi | ||
*/ | ||
export interface NestExpressBodyParserOptions { | ||
/** When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true. */ | ||
inflate?: boolean | undefined; | ||
|
||
/** | ||
* Controls the maximum request body size. If this is a number, | ||
* then the value specifies the number of bytes; if it is a string, | ||
* the value is passed to the bytes library for parsing. Defaults to '100kb'. | ||
*/ | ||
limit?: number | string | undefined; | ||
|
||
/** | ||
* The type option is used to determine what media type the middleware will parse | ||
*/ | ||
type?: string | string[] | ((req: IncomingMessage) => any) | undefined; | ||
|
||
// Catch-all for body-parser type specific options | ||
[key: string]: unknown; | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/platform-express/interfaces/nest-express-body-parser.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Interface defining possible body parser types, to be used with `NestExpressApplication.useBodyParser()`. | ||
*/ | ||
export type NestExpressBodyParserType = 'json' | 'urlencoded' | 'text' | 'raw'; |