mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
fix(api): update bodyparser config to adonis 5
This commit is contained in:
parent
8b9c210ea6
commit
e6cd4d340b
1 changed files with 136 additions and 111 deletions
|
|
@ -9,25 +9,25 @@ import { BodyParserConfig } from '@ioc:Adonis/Core/BodyParser'
|
||||||
|
|
||||||
const bodyParserConfig: BodyParserConfig = {
|
const bodyParserConfig: BodyParserConfig = {
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| White listed methods
|
| White listed methods
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| HTTP methods for which body parsing must be performed. It is a good practice
|
| HTTP methods for which body parsing must be performed. It is a good practice
|
||||||
| to avoid body parsing for `GET` requests.
|
| to avoid body parsing for `GET` requests.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
whitelistedMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],
|
whitelistedMethods: ['POST', 'PUT', 'PATCH', 'DELETE'],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| JSON parser settings
|
| JSON parser settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The settings for the JSON parser. The types defines the request content
|
| The settings for the JSON parser. The types defines the request content
|
||||||
| types which gets processed by the JSON parser.
|
| types which gets processed by the JSON parser.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
json: {
|
json: {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
limit: '1mb',
|
limit: '1mb',
|
||||||
|
|
@ -41,31 +41,44 @@ const bodyParserConfig: BodyParserConfig = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Form parser settings
|
| Form parser settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The settings for the `application/x-www-form-urlencoded` parser. The types
|
| The settings for the `application/x-www-form-urlencoded` parser. The types
|
||||||
| defines the request content types which gets processed by the form parser.
|
| defines the request content types which gets processed by the form parser.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
form: {
|
form: {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
limit: '1mb',
|
limit: '1mb',
|
||||||
queryString: {},
|
queryString: {},
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Convert empty strings to null
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Convert empty form fields to null. HTML forms results in field string
|
||||||
|
| value when the field is left blank. This option normalizes all the blank
|
||||||
|
| field values to "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
convertEmptyStringsToNull: true,
|
||||||
|
|
||||||
types: ['application/x-www-form-urlencoded'],
|
types: ['application/x-www-form-urlencoded'],
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Raw body parser settings
|
| Raw body parser settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Raw body just reads the request body stream as a plain text, which you
|
| Raw body just reads the request body stream as a plain text, which you
|
||||||
| can process by hand. This must be used when request body type is not
|
| can process by hand. This must be used when request body type is not
|
||||||
| supported by the body parser.
|
| supported by the body parser.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
raw: {
|
raw: {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
limit: '1mb',
|
limit: '1mb',
|
||||||
|
|
@ -74,105 +87,117 @@ const bodyParserConfig: BodyParserConfig = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Multipart parser settings
|
| Multipart parser settings
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The settings for the `multipart/form-data` parser. The types defines the
|
| The settings for the `multipart/form-data` parser. The types defines the
|
||||||
| request content types which gets processed by the form parser.
|
| request content types which gets processed by the form parser.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
multipart: {
|
multipart: {
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Auto process
|
| Auto process
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The auto process option will process uploaded files and writes them to
|
| The auto process option will process uploaded files and writes them to
|
||||||
| the `tmp` folder. You can turn it off and then manually use the stream
|
| the `tmp` folder. You can turn it off and then manually use the stream
|
||||||
| to pipe stream to a different destination.
|
| to pipe stream to a different destination.
|
||||||
|
|
|
|
||||||
| It is recommended to keep `autoProcess=true`. Unless you are processing bigger
|
| It is recommended to keep `autoProcess=true`. Unless you are processing bigger
|
||||||
| file sizes.
|
| file sizes.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
autoProcess: true,
|
autoProcess: true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Files to be processed manually
|
| Files to be processed manually
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| You can turn off `autoProcess` for certain routes by defining
|
| You can turn off `autoProcess` for certain routes by defining
|
||||||
| routes inside the following array.
|
| routes inside the following array.
|
||||||
|
|
|
|
||||||
| NOTE: Make sure the route pattern starts with a leading slash.
|
| NOTE: Make sure the route pattern starts with a leading slash.
|
||||||
|
|
|
|
||||||
| Correct
|
| Correct
|
||||||
| ```js
|
| ```js
|
||||||
| /projects/:id/file
|
| /projects/:id/file
|
||||||
| ```
|
| ```
|
||||||
|
|
|
|
||||||
| Incorrect
|
| Incorrect
|
||||||
| ```js
|
| ```js
|
||||||
| projects/:id/file
|
| projects/:id/file
|
||||||
| ```
|
| ```
|
||||||
*/
|
*/
|
||||||
processManually: [],
|
processManually: [],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Temporary file name
|
| Temporary file name
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| When auto processing is on. We will use this method to compute the temporary
|
| When auto processing is on. We will use this method to compute the temporary
|
||||||
| file name. AdonisJs will compute a unique `tmpPath` for you automatically,
|
| file name. AdonisJs will compute a unique `tmpPath` for you automatically,
|
||||||
| However, you can also define your own custom method.
|
| However, you can also define your own custom method.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
// tmpFileName () {
|
// tmpFileName () {
|
||||||
// },
|
// },
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Encoding
|
| Encoding
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Request body encoding
|
| Request body encoding
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Max Fields
|
| Convert empty strings to null
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The maximum number of fields allowed in the request body. The field includes
|
| Convert empty form fields to null. HTML forms results in field string
|
||||||
| text inputs and files both.
|
| value when the field is left blank. This option normalizes all the blank
|
||||||
|
|
| field values to "null"
|
||||||
*/
|
|
|
||||||
|
*/
|
||||||
|
convertEmptyStringsToNull: true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Max Fields
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The maximum number of fields allowed in the request body. The field includes
|
||||||
|
| text inputs and files both.
|
||||||
|
|
|
||||||
|
*/
|
||||||
maxFields: 1000,
|
maxFields: 1000,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Request body limit
|
| Request body limit
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The total limit to the multipart body. This includes all request files
|
| The total limit to the multipart body. This includes all request files
|
||||||
| and fields data.
|
| and fields data.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
limit: '20mb',
|
limit: '20mb',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Types
|
| Types
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The types that will be considered and parsed as multipart body.
|
| The types that will be considered and parsed as multipart body.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
types: ['multipart/form-data'],
|
types: ['multipart/form-data'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue