aboutsummaryrefslogtreecommitdiffstats
path: root/config/bodyParser.js
blob: c336e67d2ade8edf146499086b2e557d02794008 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
module.exports = {
  /*
  |--------------------------------------------------------------------------
  | JSON Parser
  |--------------------------------------------------------------------------
  |
  | Below settings are applied when the request body contains a JSON payload.
  | If you want body parser to ignore JSON payloads, then simply set `types`
  | to an empty array.
  */
  json: {
    /*
    |--------------------------------------------------------------------------
    | limit
    |--------------------------------------------------------------------------
    |
    | Defines the limit of JSON that can be sent by the client. If payload
    | is over 1mb it will not be processed.
    |
    */
    limit: '50mb',

    /*
    |--------------------------------------------------------------------------
    | strict
    |--------------------------------------------------------------------------
    |
    | When `strict` is set to true, body parser will only parse Arrays and
    | Object. Otherwise everything parseable by `JSON.parse` is parsed.
    |
    */
    strict: true,

    /*
    |--------------------------------------------------------------------------
    | types
    |--------------------------------------------------------------------------
    |
    | Which content types are processed as JSON payloads. You are free to
    | add your own types here, but the request body should be parseable
    | by `JSON.parse` method.
    |
    */
    types: [
      'application/json',
      'application/json-patch+json',
      'application/vnd.api+json',
      'application/csp-report',
    ],
  },

  /*
  |--------------------------------------------------------------------------
  | Raw Parser
  |--------------------------------------------------------------------------
  |
  |
  |
  */
  raw: {
    types: [
      'text/*',
    ],
  },

  /*
  |--------------------------------------------------------------------------
  | Form Parser
  |--------------------------------------------------------------------------
  |
  |
  |
  */
  form: {
    types: [
      'application/x-www-form-urlencoded',
    ],
  },

  /*
  |--------------------------------------------------------------------------
  | Files Parser
  |--------------------------------------------------------------------------
  |
  |
  |
  */
  files: {
    types: [
      'multipart/form-data',
    ],

    /*
    |--------------------------------------------------------------------------
    | Max Size
    |--------------------------------------------------------------------------
    |
    | Below value is the max size of all the files uploaded to the server. It
    | is validated even before files have been processed and hard exception
    | is thrown.
    |
    | Consider setting a reasonable value here, otherwise people may upload GB's
    | of files which will keep your server busy.
    |
    | Also this value is considered when `autoProcess` is set to true.
    |
    */
    maxSize: '20mb',

    /*
    |--------------------------------------------------------------------------
    | Auto Process
    |--------------------------------------------------------------------------
    |
    | Whether or not to auto-process files. Since HTTP servers handle files via
    | couple of specific endpoints. It is better to set this value off and
    | manually process the files when required.
    |
    | This value can contain a boolean or an array of route patterns
    | to be autoprocessed.
    */
    autoProcess: true,

    /*
    |--------------------------------------------------------------------------
    | Process Manually
    |--------------------------------------------------------------------------
    |
    | The list of routes that should not process files and instead rely on
    | manual process. This list should only contain routes when autoProcess
    | is to true. Otherwise everything is processed manually.
    |
    */
    processManually: [],

    /*
    |--------------------------------------------------------------------------
    | Temporary file name
    |--------------------------------------------------------------------------
    |
    | Define a function, which should return a string to be used as the
    | tmp file name.
    |
    | If not defined, Bodyparser will use `uuid` as the tmp file name.
    |
    | To be defined as. If you are defining the function, then do make sure
    | to return a value from it.
    |
    | tmpFileName () {
    |   return 'some-unique-value'
    | }
    |
    */
  },
};