fastify 3.22.0 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/build/build-validation.js +2 -0
  2. package/build/sync-version.js +11 -0
  3. package/docs/Getting-Started.md +14 -0
  4. package/docs/Hooks.md +1 -1
  5. package/docs/Recommendations.md +55 -19
  6. package/docs/Request.md +1 -1
  7. package/docs/Routes.md +2 -0
  8. package/docs/Server.md +13 -1
  9. package/docs/TypeScript.md +3 -0
  10. package/docs/Validation-and-Serialization.md +10 -2
  11. package/fastify.d.ts +15 -0
  12. package/fastify.js +7 -24
  13. package/lib/configValidator.js +455 -423
  14. package/lib/logger.js +1 -1
  15. package/lib/pluginUtils.js +1 -3
  16. package/lib/reply.js +8 -3
  17. package/lib/request.js +9 -3
  18. package/lib/schema-controller.js +11 -2
  19. package/lib/server.js +1 -0
  20. package/lib/symbols.js +1 -0
  21. package/package.json +5 -5
  22. package/test/bundler/README.md +7 -7
  23. package/test/bundler/webpack/bundler-test.js +2 -6
  24. package/test/internals/initialConfig.test.js +2 -0
  25. package/test/internals/logger.test.js +20 -0
  26. package/test/internals/reply.test.js +43 -1
  27. package/test/internals/request.test.js +47 -0
  28. package/test/internals/version.test.js +6 -34
  29. package/test/reply-error.test.js +28 -0
  30. package/test/requestTimeout.test.js +50 -0
  31. package/test/route-hooks.test.js +55 -0
  32. package/test/schema-feature.test.js +315 -0
  33. package/test/schema-special-usage.test.js +1 -1
  34. package/test/stream.test.js +2 -2
  35. package/test/types/content-type-parser.test-d.ts +1 -1
  36. package/test/types/fastify.test-d.ts +15 -0
  37. package/test/types/instance.test-d.ts +1 -1
  38. package/test/types/logger.test-d.ts +1 -1
  39. package/test/types/register.test-d.ts +13 -1
  40. package/types/instance.d.ts +1 -1
  41. package/types/register.d.ts +2 -1
  42. package/out +0 -431
@@ -15,6 +15,7 @@ var validate = (function() {
15
15
  if (data.connectionTimeout === undefined) data.connectionTimeout = 0;
16
16
  if (data.keepAliveTimeout === undefined) data.keepAliveTimeout = 5000;
17
17
  if (data.maxRequestsPerSocket === undefined) data.maxRequestsPerSocket = 0;
18
+ if (data.requestTimeout === undefined) data.requestTimeout = 0;
18
19
  if (data.bodyLimit === undefined) data.bodyLimit = 1048576;
19
20
  if (data.caseSensitive === undefined) data.caseSensitive = true;
20
21
  if (data.ignoreTrailingSlash === undefined) data.ignoreTrailingSlash = false;
@@ -114,7 +115,7 @@ var validate = (function() {
114
115
  }
115
116
  var valid1 = errors === errs_1;
116
117
  if (valid1) {
117
- var data1 = data.bodyLimit;
118
+ var data1 = data.requestTimeout;
118
119
  var errs_1 = errors;
119
120
  if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
120
121
  var dataType1 = typeof data1;
@@ -124,8 +125,8 @@ var validate = (function() {
124
125
  else {
125
126
  validate.errors = [{
126
127
  keyword: 'type',
127
- dataPath: (dataPath || '') + '.bodyLimit',
128
- schemaPath: '#/properties/bodyLimit/type',
128
+ dataPath: (dataPath || '') + '.requestTimeout',
129
+ schemaPath: '#/properties/requestTimeout/type',
129
130
  params: {
130
131
  type: 'integer'
131
132
  },
@@ -135,298 +136,297 @@ var validate = (function() {
135
136
  }
136
137
  if (coerced1 !== undefined) {
137
138
  data1 = coerced1;
138
- data['bodyLimit'] = coerced1;
139
+ data['requestTimeout'] = coerced1;
139
140
  }
140
141
  }
141
142
  var valid1 = errors === errs_1;
142
143
  if (valid1) {
143
- var data1 = data.caseSensitive;
144
+ var data1 = data.bodyLimit;
144
145
  var errs_1 = errors;
145
- if (typeof data1 !== "boolean") {
146
+ if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
146
147
  var dataType1 = typeof data1;
147
148
  var coerced1 = undefined;
148
149
  if (coerced1 !== undefined);
149
- else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
150
- else if (data1 === 'true' || data1 === 1) coerced1 = true;
150
+ else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
151
151
  else {
152
152
  validate.errors = [{
153
153
  keyword: 'type',
154
- dataPath: (dataPath || '') + '.caseSensitive',
155
- schemaPath: '#/properties/caseSensitive/type',
154
+ dataPath: (dataPath || '') + '.bodyLimit',
155
+ schemaPath: '#/properties/bodyLimit/type',
156
156
  params: {
157
- type: 'boolean'
157
+ type: 'integer'
158
158
  },
159
- message: 'should be boolean'
159
+ message: 'should be integer'
160
160
  }];
161
161
  return false;
162
162
  }
163
163
  if (coerced1 !== undefined) {
164
164
  data1 = coerced1;
165
- data['caseSensitive'] = coerced1;
165
+ data['bodyLimit'] = coerced1;
166
166
  }
167
167
  }
168
168
  var valid1 = errors === errs_1;
169
169
  if (valid1) {
170
- var data1 = data.http2;
171
- if (data1 === undefined) {
172
- valid1 = true;
173
- } else {
174
- var errs_1 = errors;
175
- if (typeof data1 !== "boolean") {
176
- var dataType1 = typeof data1;
177
- var coerced1 = undefined;
178
- if (coerced1 !== undefined);
179
- else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
180
- else if (data1 === 'true' || data1 === 1) coerced1 = true;
181
- else {
182
- validate.errors = [{
183
- keyword: 'type',
184
- dataPath: (dataPath || '') + '.http2',
185
- schemaPath: '#/properties/http2/type',
186
- params: {
187
- type: 'boolean'
188
- },
189
- message: 'should be boolean'
190
- }];
191
- return false;
192
- }
193
- if (coerced1 !== undefined) {
194
- data1 = coerced1;
195
- data['http2'] = coerced1;
196
- }
170
+ var data1 = data.caseSensitive;
171
+ var errs_1 = errors;
172
+ if (typeof data1 !== "boolean") {
173
+ var dataType1 = typeof data1;
174
+ var coerced1 = undefined;
175
+ if (coerced1 !== undefined);
176
+ else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
177
+ else if (data1 === 'true' || data1 === 1) coerced1 = true;
178
+ else {
179
+ validate.errors = [{
180
+ keyword: 'type',
181
+ dataPath: (dataPath || '') + '.caseSensitive',
182
+ schemaPath: '#/properties/caseSensitive/type',
183
+ params: {
184
+ type: 'boolean'
185
+ },
186
+ message: 'should be boolean'
187
+ }];
188
+ return false;
189
+ }
190
+ if (coerced1 !== undefined) {
191
+ data1 = coerced1;
192
+ data['caseSensitive'] = coerced1;
197
193
  }
198
- var valid1 = errors === errs_1;
199
194
  }
195
+ var valid1 = errors === errs_1;
200
196
  if (valid1) {
201
- var data1 = data.https;
197
+ var data1 = data.http2;
202
198
  if (data1 === undefined) {
203
199
  valid1 = true;
204
200
  } else {
205
201
  var errs_1 = errors;
206
- var errs__1 = errors;
207
- var valid1 = true;
208
- var errs_2 = errors;
209
- var errs__2 = errors;
210
- var errs_3 = errors;
211
- var errs__3 = errors,
212
- prevValid3 = false,
213
- valid3 = false,
214
- passingSchemas3 = null;
215
- var errs_4 = errors;
216
202
  if (typeof data1 !== "boolean") {
217
- var dataType4 = typeof data1;
218
- var coerced4 = undefined;
219
- if (coerced4 !== undefined);
220
- else if (data1 === 'false' || data1 === 0 || data1 === null) coerced4 = false;
221
- else if (data1 === 'true' || data1 === 1) coerced4 = true;
222
- else {
223
- var err = {};
224
- if (vErrors === null) vErrors = [err];
225
- else vErrors.push(err);
226
- errors++;
227
- }
228
- if (coerced4 !== undefined) {
229
- data1 = coerced4;
230
- data['https'] = coerced4;
231
- }
232
- }
233
- var valid4 = errors === errs_4;
234
- if (valid4) {
235
- valid3 = prevValid3 = true;
236
- passingSchemas3 = 0;
237
- }
238
- var errs_4 = errors;
239
- if (data1 !== null) {
240
- var dataType4 = typeof data1;
241
- var coerced4 = undefined;
242
- if (coerced4 !== undefined);
243
- else if (data1 === '' || data1 === 0 || data1 === false) coerced4 = null;
203
+ var dataType1 = typeof data1;
204
+ var coerced1 = undefined;
205
+ if (coerced1 !== undefined);
206
+ else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
207
+ else if (data1 === 'true' || data1 === 1) coerced1 = true;
244
208
  else {
245
- var err = {};
246
- if (vErrors === null) vErrors = [err];
247
- else vErrors.push(err);
248
- errors++;
209
+ validate.errors = [{
210
+ keyword: 'type',
211
+ dataPath: (dataPath || '') + '.http2',
212
+ schemaPath: '#/properties/http2/type',
213
+ params: {
214
+ type: 'boolean'
215
+ },
216
+ message: 'should be boolean'
217
+ }];
218
+ return false;
249
219
  }
250
- if (coerced4 !== undefined) {
251
- data1 = coerced4;
252
- data['https'] = coerced4;
220
+ if (coerced1 !== undefined) {
221
+ data1 = coerced1;
222
+ data['http2'] = coerced1;
253
223
  }
254
224
  }
255
- var valid4 = errors === errs_4;
256
- if (valid4 && prevValid3) {
257
- valid3 = false;
258
- passingSchemas3 = [passingSchemas3, 1];
225
+ var valid1 = errors === errs_1;
226
+ }
227
+ if (valid1) {
228
+ var data1 = data.https;
229
+ if (data1 === undefined) {
230
+ valid1 = true;
259
231
  } else {
232
+ var errs_1 = errors;
233
+ var errs__1 = errors;
234
+ var valid1 = true;
235
+ var errs_2 = errors;
236
+ var errs__2 = errors;
237
+ var errs_3 = errors;
238
+ var errs__3 = errors,
239
+ prevValid3 = false,
240
+ valid3 = false,
241
+ passingSchemas3 = null;
242
+ var errs_4 = errors;
243
+ if (typeof data1 !== "boolean") {
244
+ var dataType4 = typeof data1;
245
+ var coerced4 = undefined;
246
+ if (coerced4 !== undefined);
247
+ else if (data1 === 'false' || data1 === 0 || data1 === null) coerced4 = false;
248
+ else if (data1 === 'true' || data1 === 1) coerced4 = true;
249
+ else {
250
+ var err = {};
251
+ if (vErrors === null) vErrors = [err];
252
+ else vErrors.push(err);
253
+ errors++;
254
+ }
255
+ if (coerced4 !== undefined) {
256
+ data1 = coerced4;
257
+ data['https'] = coerced4;
258
+ }
259
+ }
260
+ var valid4 = errors === errs_4;
260
261
  if (valid4) {
261
262
  valid3 = prevValid3 = true;
262
- passingSchemas3 = 1;
263
+ passingSchemas3 = 0;
263
264
  }
264
265
  var errs_4 = errors;
265
- if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
266
- if (true) {
267
- var errs__4 = errors;
268
- var valid5 = true;
269
- for (var key4 in data1) {
270
- var isAdditional4 = !(false || key4 == 'allowHTTP1');
271
- if (isAdditional4) {
272
- delete data1[key4];
266
+ if (data1 !== null) {
267
+ var dataType4 = typeof data1;
268
+ var coerced4 = undefined;
269
+ if (coerced4 !== undefined);
270
+ else if (data1 === '' || data1 === 0 || data1 === false) coerced4 = null;
271
+ else {
272
+ var err = {};
273
+ if (vErrors === null) vErrors = [err];
274
+ else vErrors.push(err);
275
+ errors++;
276
+ }
277
+ if (coerced4 !== undefined) {
278
+ data1 = coerced4;
279
+ data['https'] = coerced4;
280
+ }
281
+ }
282
+ var valid4 = errors === errs_4;
283
+ if (valid4 && prevValid3) {
284
+ valid3 = false;
285
+ passingSchemas3 = [passingSchemas3, 1];
286
+ } else {
287
+ if (valid4) {
288
+ valid3 = prevValid3 = true;
289
+ passingSchemas3 = 1;
290
+ }
291
+ var errs_4 = errors;
292
+ if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
293
+ if (true) {
294
+ var errs__4 = errors;
295
+ var valid5 = true;
296
+ for (var key4 in data1) {
297
+ var isAdditional4 = !(false || key4 == 'allowHTTP1');
298
+ if (isAdditional4) {
299
+ delete data1[key4];
300
+ }
273
301
  }
274
- }
275
- if (valid5) {
276
- var data2 = data1.allowHTTP1;
277
- if (data2 === undefined) {
278
- valid5 = false;
279
- var err = {};
280
- if (vErrors === null) vErrors = [err];
281
- else vErrors.push(err);
282
- errors++;
283
- } else {
284
- var errs_5 = errors;
285
- if (typeof data2 !== "boolean") {
286
- var dataType5 = typeof data2;
287
- var coerced5 = undefined;
288
- if (coerced5 !== undefined);
289
- else if (data2 === 'false' || data2 === 0 || data2 === null) coerced5 = false;
290
- else if (data2 === 'true' || data2 === 1) coerced5 = true;
291
- else {
292
- var err = {};
293
- if (vErrors === null) vErrors = [err];
294
- else vErrors.push(err);
295
- errors++;
296
- }
297
- if (coerced5 !== undefined) {
298
- data2 = coerced5;
299
- data1['allowHTTP1'] = coerced5;
302
+ if (valid5) {
303
+ var data2 = data1.allowHTTP1;
304
+ if (data2 === undefined) {
305
+ valid5 = false;
306
+ var err = {};
307
+ if (vErrors === null) vErrors = [err];
308
+ else vErrors.push(err);
309
+ errors++;
310
+ } else {
311
+ var errs_5 = errors;
312
+ if (typeof data2 !== "boolean") {
313
+ var dataType5 = typeof data2;
314
+ var coerced5 = undefined;
315
+ if (coerced5 !== undefined);
316
+ else if (data2 === 'false' || data2 === 0 || data2 === null) coerced5 = false;
317
+ else if (data2 === 'true' || data2 === 1) coerced5 = true;
318
+ else {
319
+ var err = {};
320
+ if (vErrors === null) vErrors = [err];
321
+ else vErrors.push(err);
322
+ errors++;
323
+ }
324
+ if (coerced5 !== undefined) {
325
+ data2 = coerced5;
326
+ data1['allowHTTP1'] = coerced5;
327
+ }
300
328
  }
329
+ var valid5 = errors === errs_5;
301
330
  }
302
- var valid5 = errors === errs_5;
331
+ if (valid5) {}
303
332
  }
304
- if (valid5) {}
333
+ if (errs__4 == errors) {}
305
334
  }
306
- if (errs__4 == errors) {}
335
+ } else {
336
+ var err = {};
337
+ if (vErrors === null) vErrors = [err];
338
+ else vErrors.push(err);
339
+ errors++;
307
340
  }
308
- } else {
341
+ if (errors === errs_4) {}
342
+ var valid4 = errors === errs_4;
343
+ if (valid4 && prevValid3) {
344
+ valid3 = false;
345
+ passingSchemas3 = [passingSchemas3, 2];
346
+ } else {
347
+ if (valid4) {
348
+ valid3 = prevValid3 = true;
349
+ passingSchemas3 = 2;
350
+ }
351
+ }
352
+ }
353
+ if (!valid3) {
309
354
  var err = {};
310
355
  if (vErrors === null) vErrors = [err];
311
356
  else vErrors.push(err);
312
357
  errors++;
358
+ } else {
359
+ errors = errs__3;
360
+ if (vErrors !== null) {
361
+ if (errs__3) vErrors.length = errs__3;
362
+ else vErrors = null;
363
+ }
313
364
  }
314
- if (errors === errs_4) {}
315
- var valid4 = errors === errs_4;
316
- if (valid4 && prevValid3) {
317
- valid3 = false;
318
- passingSchemas3 = [passingSchemas3, 2];
365
+ if (errors === errs_3) {}
366
+ var valid3 = errors === errs_3;
367
+ if (valid3) {
368
+ var err = {};
369
+ if (vErrors === null) vErrors = [err];
370
+ else vErrors.push(err);
371
+ errors++;
319
372
  } else {
320
- if (valid4) {
321
- valid3 = prevValid3 = true;
322
- passingSchemas3 = 2;
373
+ errors = errs__2;
374
+ if (vErrors !== null) {
375
+ if (errs__2) vErrors.length = errs__2;
376
+ else vErrors = null;
323
377
  }
324
378
  }
325
- }
326
- if (!valid3) {
327
- var err = {};
328
- if (vErrors === null) vErrors = [err];
329
- else vErrors.push(err);
330
- errors++;
331
- } else {
332
- errors = errs__3;
379
+ if (errors === errs_2) {}
380
+ var valid2 = errors === errs_2;
381
+ errors = errs__1;
333
382
  if (vErrors !== null) {
334
- if (errs__3) vErrors.length = errs__3;
383
+ if (errs__1) vErrors.length = errs__1;
335
384
  else vErrors = null;
336
385
  }
337
- }
338
- if (errors === errs_3) {}
339
- var valid3 = errors === errs_3;
340
- if (valid3) {
341
- var err = {};
342
- if (vErrors === null) vErrors = [err];
343
- else vErrors.push(err);
344
- errors++;
345
- } else {
346
- errors = errs__2;
347
- if (vErrors !== null) {
348
- if (errs__2) vErrors.length = errs__2;
349
- else vErrors = null;
386
+ if (valid2) {
387
+ var errs_2 = errors;
388
+ customRule0.errors = null;
389
+ var errs__2 = errors;
390
+ var valid2;
391
+ valid2 = customRule0.call(self, validate.schema.properties.https.then.setDefaultValue, data1, validate.schema.properties.https.then, (dataPath || '') + '.https', data, 'https', rootData);
392
+ if (data) data1 = data['https'];
393
+ if (!valid2) {
394
+ validate.errors = [{
395
+ keyword: 'setDefaultValue',
396
+ dataPath: (dataPath || '') + '.https',
397
+ schemaPath: '#/properties/https/then/setDefaultValue',
398
+ params: {
399
+ keyword: 'setDefaultValue'
400
+ },
401
+ message: 'should pass "setDefaultValue" keyword validation'
402
+ }];
403
+ return false;
404
+ } else {}
405
+ if (errors === errs_2) {}
406
+ var valid2 = errors === errs_2;
407
+ valid1 = valid2;
350
408
  }
351
- }
352
- if (errors === errs_2) {}
353
- var valid2 = errors === errs_2;
354
- errors = errs__1;
355
- if (vErrors !== null) {
356
- if (errs__1) vErrors.length = errs__1;
357
- else vErrors = null;
358
- }
359
- if (valid2) {
360
- var errs_2 = errors;
361
- customRule0.errors = null;
362
- var errs__2 = errors;
363
- var valid2;
364
- valid2 = customRule0.call(self, validate.schema.properties.https.then.setDefaultValue, data1, validate.schema.properties.https.then, (dataPath || '') + '.https', data, 'https', rootData);
365
- if (data) data1 = data['https'];
366
- if (!valid2) {
367
- validate.errors = [{
368
- keyword: 'setDefaultValue',
409
+ if (!valid1) {
410
+ var err = {
411
+ keyword: 'if',
369
412
  dataPath: (dataPath || '') + '.https',
370
- schemaPath: '#/properties/https/then/setDefaultValue',
413
+ schemaPath: '#/properties/https/if',
371
414
  params: {
372
- keyword: 'setDefaultValue'
415
+ failingKeyword: 'then'
373
416
  },
374
- message: 'should pass "setDefaultValue" keyword validation'
375
- }];
417
+ message: 'should match "' + 'then' + '" schema'
418
+ };
419
+ if (vErrors === null) vErrors = [err];
420
+ else vErrors.push(err);
421
+ errors++;
422
+ validate.errors = vErrors;
376
423
  return false;
377
424
  } else {}
378
- if (errors === errs_2) {}
379
- var valid2 = errors === errs_2;
380
- valid1 = valid2;
381
- }
382
- if (!valid1) {
383
- var err = {
384
- keyword: 'if',
385
- dataPath: (dataPath || '') + '.https',
386
- schemaPath: '#/properties/https/if',
387
- params: {
388
- failingKeyword: 'then'
389
- },
390
- message: 'should match "' + 'then' + '" schema'
391
- };
392
- if (vErrors === null) vErrors = [err];
393
- else vErrors.push(err);
394
- errors++;
395
- validate.errors = vErrors;
396
- return false;
397
- } else {}
398
- if (errors === errs_1) {}
399
- var valid1 = errors === errs_1;
400
- }
401
- if (valid1) {
402
- var data1 = data.ignoreTrailingSlash;
403
- var errs_1 = errors;
404
- if (typeof data1 !== "boolean") {
405
- var dataType1 = typeof data1;
406
- var coerced1 = undefined;
407
- if (coerced1 !== undefined);
408
- else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
409
- else if (data1 === 'true' || data1 === 1) coerced1 = true;
410
- else {
411
- validate.errors = [{
412
- keyword: 'type',
413
- dataPath: (dataPath || '') + '.ignoreTrailingSlash',
414
- schemaPath: '#/properties/ignoreTrailingSlash/type',
415
- params: {
416
- type: 'boolean'
417
- },
418
- message: 'should be boolean'
419
- }];
420
- return false;
421
- }
422
- if (coerced1 !== undefined) {
423
- data1 = coerced1;
424
- data['ignoreTrailingSlash'] = coerced1;
425
- }
425
+ if (errors === errs_1) {}
426
+ var valid1 = errors === errs_1;
426
427
  }
427
- var valid1 = errors === errs_1;
428
428
  if (valid1) {
429
- var data1 = data.disableRequestLogging;
429
+ var data1 = data.ignoreTrailingSlash;
430
430
  var errs_1 = errors;
431
431
  if (typeof data1 !== "boolean") {
432
432
  var dataType1 = typeof data1;
@@ -437,8 +437,8 @@ var validate = (function() {
437
437
  else {
438
438
  validate.errors = [{
439
439
  keyword: 'type',
440
- dataPath: (dataPath || '') + '.disableRequestLogging',
441
- schemaPath: '#/properties/disableRequestLogging/type',
440
+ dataPath: (dataPath || '') + '.ignoreTrailingSlash',
441
+ schemaPath: '#/properties/ignoreTrailingSlash/type',
442
442
  params: {
443
443
  type: 'boolean'
444
444
  },
@@ -448,12 +448,12 @@ var validate = (function() {
448
448
  }
449
449
  if (coerced1 !== undefined) {
450
450
  data1 = coerced1;
451
- data['disableRequestLogging'] = coerced1;
451
+ data['ignoreTrailingSlash'] = coerced1;
452
452
  }
453
453
  }
454
454
  var valid1 = errors === errs_1;
455
455
  if (valid1) {
456
- var data1 = data.jsonShorthand;
456
+ var data1 = data.disableRequestLogging;
457
457
  var errs_1 = errors;
458
458
  if (typeof data1 !== "boolean") {
459
459
  var dataType1 = typeof data1;
@@ -464,8 +464,8 @@ var validate = (function() {
464
464
  else {
465
465
  validate.errors = [{
466
466
  keyword: 'type',
467
- dataPath: (dataPath || '') + '.jsonShorthand',
468
- schemaPath: '#/properties/jsonShorthand/type',
467
+ dataPath: (dataPath || '') + '.disableRequestLogging',
468
+ schemaPath: '#/properties/disableRequestLogging/type',
469
469
  params: {
470
470
  type: 'boolean'
471
471
  },
@@ -475,65 +475,65 @@ var validate = (function() {
475
475
  }
476
476
  if (coerced1 !== undefined) {
477
477
  data1 = coerced1;
478
- data['jsonShorthand'] = coerced1;
478
+ data['disableRequestLogging'] = coerced1;
479
479
  }
480
480
  }
481
481
  var valid1 = errors === errs_1;
482
482
  if (valid1) {
483
- var data1 = data.maxParamLength;
483
+ var data1 = data.jsonShorthand;
484
484
  var errs_1 = errors;
485
- if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
485
+ if (typeof data1 !== "boolean") {
486
486
  var dataType1 = typeof data1;
487
487
  var coerced1 = undefined;
488
488
  if (coerced1 !== undefined);
489
- else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
489
+ else if (data1 === 'false' || data1 === 0 || data1 === null) coerced1 = false;
490
+ else if (data1 === 'true' || data1 === 1) coerced1 = true;
490
491
  else {
491
492
  validate.errors = [{
492
493
  keyword: 'type',
493
- dataPath: (dataPath || '') + '.maxParamLength',
494
- schemaPath: '#/properties/maxParamLength/type',
494
+ dataPath: (dataPath || '') + '.jsonShorthand',
495
+ schemaPath: '#/properties/jsonShorthand/type',
495
496
  params: {
496
- type: 'integer'
497
+ type: 'boolean'
497
498
  },
498
- message: 'should be integer'
499
+ message: 'should be boolean'
499
500
  }];
500
501
  return false;
501
502
  }
502
503
  if (coerced1 !== undefined) {
503
504
  data1 = coerced1;
504
- data['maxParamLength'] = coerced1;
505
+ data['jsonShorthand'] = coerced1;
505
506
  }
506
507
  }
507
508
  var valid1 = errors === errs_1;
508
509
  if (valid1) {
509
- var data1 = data.onProtoPoisoning;
510
+ var data1 = data.maxParamLength;
510
511
  var errs_1 = errors;
511
- if (typeof data1 !== "string") {
512
+ if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
512
513
  var dataType1 = typeof data1;
513
514
  var coerced1 = undefined;
514
515
  if (coerced1 !== undefined);
515
- else if (dataType1 == 'number' || dataType1 == 'boolean') coerced1 = '' + data1;
516
- else if (data1 === null) coerced1 = '';
516
+ else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
517
517
  else {
518
518
  validate.errors = [{
519
519
  keyword: 'type',
520
- dataPath: (dataPath || '') + '.onProtoPoisoning',
521
- schemaPath: '#/properties/onProtoPoisoning/type',
520
+ dataPath: (dataPath || '') + '.maxParamLength',
521
+ schemaPath: '#/properties/maxParamLength/type',
522
522
  params: {
523
- type: 'string'
523
+ type: 'integer'
524
524
  },
525
- message: 'should be string'
525
+ message: 'should be integer'
526
526
  }];
527
527
  return false;
528
528
  }
529
529
  if (coerced1 !== undefined) {
530
530
  data1 = coerced1;
531
- data['onProtoPoisoning'] = coerced1;
531
+ data['maxParamLength'] = coerced1;
532
532
  }
533
533
  }
534
534
  var valid1 = errors === errs_1;
535
535
  if (valid1) {
536
- var data1 = data.onConstructorPoisoning;
536
+ var data1 = data.onProtoPoisoning;
537
537
  var errs_1 = errors;
538
538
  if (typeof data1 !== "string") {
539
539
  var dataType1 = typeof data1;
@@ -544,8 +544,8 @@ var validate = (function() {
544
544
  else {
545
545
  validate.errors = [{
546
546
  keyword: 'type',
547
- dataPath: (dataPath || '') + '.onConstructorPoisoning',
548
- schemaPath: '#/properties/onConstructorPoisoning/type',
547
+ dataPath: (dataPath || '') + '.onProtoPoisoning',
548
+ schemaPath: '#/properties/onProtoPoisoning/type',
549
549
  params: {
550
550
  type: 'string'
551
551
  },
@@ -555,65 +555,65 @@ var validate = (function() {
555
555
  }
556
556
  if (coerced1 !== undefined) {
557
557
  data1 = coerced1;
558
- data['onConstructorPoisoning'] = coerced1;
558
+ data['onProtoPoisoning'] = coerced1;
559
559
  }
560
560
  }
561
561
  var valid1 = errors === errs_1;
562
562
  if (valid1) {
563
- var data1 = data.pluginTimeout;
563
+ var data1 = data.onConstructorPoisoning;
564
564
  var errs_1 = errors;
565
- if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
565
+ if (typeof data1 !== "string") {
566
566
  var dataType1 = typeof data1;
567
567
  var coerced1 = undefined;
568
568
  if (coerced1 !== undefined);
569
- else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
569
+ else if (dataType1 == 'number' || dataType1 == 'boolean') coerced1 = '' + data1;
570
+ else if (data1 === null) coerced1 = '';
570
571
  else {
571
572
  validate.errors = [{
572
573
  keyword: 'type',
573
- dataPath: (dataPath || '') + '.pluginTimeout',
574
- schemaPath: '#/properties/pluginTimeout/type',
574
+ dataPath: (dataPath || '') + '.onConstructorPoisoning',
575
+ schemaPath: '#/properties/onConstructorPoisoning/type',
575
576
  params: {
576
- type: 'integer'
577
+ type: 'string'
577
578
  },
578
- message: 'should be integer'
579
+ message: 'should be string'
579
580
  }];
580
581
  return false;
581
582
  }
582
583
  if (coerced1 !== undefined) {
583
584
  data1 = coerced1;
584
- data['pluginTimeout'] = coerced1;
585
+ data['onConstructorPoisoning'] = coerced1;
585
586
  }
586
587
  }
587
588
  var valid1 = errors === errs_1;
588
589
  if (valid1) {
589
- var data1 = data.requestIdHeader;
590
+ var data1 = data.pluginTimeout;
590
591
  var errs_1 = errors;
591
- if (typeof data1 !== "string") {
592
+ if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
592
593
  var dataType1 = typeof data1;
593
594
  var coerced1 = undefined;
594
595
  if (coerced1 !== undefined);
595
- else if (dataType1 == 'number' || dataType1 == 'boolean') coerced1 = '' + data1;
596
- else if (data1 === null) coerced1 = '';
596
+ else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
597
597
  else {
598
598
  validate.errors = [{
599
599
  keyword: 'type',
600
- dataPath: (dataPath || '') + '.requestIdHeader',
601
- schemaPath: '#/properties/requestIdHeader/type',
600
+ dataPath: (dataPath || '') + '.pluginTimeout',
601
+ schemaPath: '#/properties/pluginTimeout/type',
602
602
  params: {
603
- type: 'string'
603
+ type: 'integer'
604
604
  },
605
- message: 'should be string'
605
+ message: 'should be integer'
606
606
  }];
607
607
  return false;
608
608
  }
609
609
  if (coerced1 !== undefined) {
610
610
  data1 = coerced1;
611
- data['requestIdHeader'] = coerced1;
611
+ data['pluginTimeout'] = coerced1;
612
612
  }
613
613
  }
614
614
  var valid1 = errors === errs_1;
615
615
  if (valid1) {
616
- var data1 = data.requestIdLogLabel;
616
+ var data1 = data.requestIdHeader;
617
617
  var errs_1 = errors;
618
618
  if (typeof data1 !== "string") {
619
619
  var dataType1 = typeof data1;
@@ -624,8 +624,8 @@ var validate = (function() {
624
624
  else {
625
625
  validate.errors = [{
626
626
  keyword: 'type',
627
- dataPath: (dataPath || '') + '.requestIdLogLabel',
628
- schemaPath: '#/properties/requestIdLogLabel/type',
627
+ dataPath: (dataPath || '') + '.requestIdHeader',
628
+ schemaPath: '#/properties/requestIdHeader/type',
629
629
  params: {
630
630
  type: 'string'
631
631
  },
@@ -635,190 +635,101 @@ var validate = (function() {
635
635
  }
636
636
  if (coerced1 !== undefined) {
637
637
  data1 = coerced1;
638
- data['requestIdLogLabel'] = coerced1;
638
+ data['requestIdHeader'] = coerced1;
639
639
  }
640
640
  }
641
641
  var valid1 = errors === errs_1;
642
642
  if (valid1) {
643
- var data1 = data.http2SessionTimeout;
643
+ var data1 = data.requestIdLogLabel;
644
644
  var errs_1 = errors;
645
- if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
645
+ if (typeof data1 !== "string") {
646
646
  var dataType1 = typeof data1;
647
647
  var coerced1 = undefined;
648
648
  if (coerced1 !== undefined);
649
- else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
649
+ else if (dataType1 == 'number' || dataType1 == 'boolean') coerced1 = '' + data1;
650
+ else if (data1 === null) coerced1 = '';
650
651
  else {
651
652
  validate.errors = [{
652
653
  keyword: 'type',
653
- dataPath: (dataPath || '') + '.http2SessionTimeout',
654
- schemaPath: '#/properties/http2SessionTimeout/type',
654
+ dataPath: (dataPath || '') + '.requestIdLogLabel',
655
+ schemaPath: '#/properties/requestIdLogLabel/type',
655
656
  params: {
656
- type: 'integer'
657
+ type: 'string'
657
658
  },
658
- message: 'should be integer'
659
+ message: 'should be string'
659
660
  }];
660
661
  return false;
661
662
  }
662
663
  if (coerced1 !== undefined) {
663
664
  data1 = coerced1;
664
- data['http2SessionTimeout'] = coerced1;
665
+ data['requestIdLogLabel'] = coerced1;
665
666
  }
666
667
  }
667
668
  var valid1 = errors === errs_1;
668
669
  if (valid1) {
669
- var data1 = data.versioning;
670
- if (data1 === undefined) {
671
- valid1 = true;
672
- } else {
673
- var errs_1 = errors;
674
- if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
675
- var missing1;
676
- if (((data1.storage === undefined) && (missing1 = '.storage')) || ((data1.deriveVersion === undefined) && (missing1 = '.deriveVersion'))) {
677
- validate.errors = [{
678
- keyword: 'required',
679
- dataPath: (dataPath || '') + '.versioning',
680
- schemaPath: '#/properties/versioning/required',
681
- params: {
682
- missingProperty: '' + missing1 + ''
683
- },
684
- message: 'should have required property \'' + missing1 + '\''
685
- }];
686
- return false;
687
- } else {
688
- var errs__1 = errors;
689
- var valid2 = true;
690
- for (var key1 in data1) {
691
- var isAdditional1 = !(false || key1 == 'storage' || key1 == 'deriveVersion');
692
- if (isAdditional1) {}
693
- }
694
- if (valid2) {
695
- if (valid2) {
696
- if (valid2) {}
697
- }
698
- }
699
- if (errs__1 == errors) {}
700
- }
701
- } else {
670
+ var data1 = data.http2SessionTimeout;
671
+ var errs_1 = errors;
672
+ if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
673
+ var dataType1 = typeof data1;
674
+ var coerced1 = undefined;
675
+ if (coerced1 !== undefined);
676
+ else if (dataType1 == 'boolean' || data1 === null || (dataType1 == 'string' && data1 && data1 == +data1 && !(data1 % 1))) coerced1 = +data1;
677
+ else {
702
678
  validate.errors = [{
703
679
  keyword: 'type',
704
- dataPath: (dataPath || '') + '.versioning',
705
- schemaPath: '#/properties/versioning/type',
680
+ dataPath: (dataPath || '') + '.http2SessionTimeout',
681
+ schemaPath: '#/properties/http2SessionTimeout/type',
706
682
  params: {
707
- type: 'object'
683
+ type: 'integer'
708
684
  },
709
- message: 'should be object'
685
+ message: 'should be integer'
710
686
  }];
711
687
  return false;
712
688
  }
713
- if (errors === errs_1) {}
714
- var valid1 = errors === errs_1;
689
+ if (coerced1 !== undefined) {
690
+ data1 = coerced1;
691
+ data['http2SessionTimeout'] = coerced1;
692
+ }
715
693
  }
694
+ var valid1 = errors === errs_1;
716
695
  if (valid1) {
717
- var data1 = data.constraints;
696
+ var data1 = data.versioning;
718
697
  if (data1 === undefined) {
719
698
  valid1 = true;
720
699
  } else {
721
700
  var errs_1 = errors;
722
701
  if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
723
- var errs__1 = errors;
724
- var valid2 = true;
725
- for (var key1 in data1) {
726
- var data2 = data1[key1];
727
- var errs_2 = errors;
728
- if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
729
- var missing2;
730
- if (((data2.storage === undefined) && (missing2 = '.storage')) || ((data2.validate === undefined) && (missing2 = '.validate')) || ((data2.deriveConstraint === undefined) && (missing2 = '.deriveConstraint'))) {
731
- validate.errors = [{
732
- keyword: 'required',
733
- dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
734
- schemaPath: '#/properties/constraints/additionalProperties/required',
735
- params: {
736
- missingProperty: '' + missing2 + ''
737
- },
738
- message: 'should have required property \'' + missing2 + '\''
739
- }];
740
- return false;
741
- } else {
742
- var errs__2 = errors;
743
- var valid3 = true;
744
- for (var key2 in data2) {
745
- var isAdditional2 = !(false || key2 == 'name' || key2 == 'storage' || key2 == 'validate' || key2 == 'deriveConstraint');
746
- if (isAdditional2) {}
747
- }
748
- if (valid3) {
749
- var data3 = data2.name;
750
- if (data3 === undefined) {
751
- valid3 = false;
752
- validate.errors = [{
753
- keyword: 'required',
754
- dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
755
- schemaPath: '#/properties/constraints/additionalProperties/required',
756
- params: {
757
- missingProperty: 'name'
758
- },
759
- message: 'should have required property \'name\''
760
- }];
761
- return false;
762
- } else {
763
- var errs_3 = errors;
764
- if (typeof data3 !== "string") {
765
- var dataType3 = typeof data3;
766
- var coerced3 = undefined;
767
- if (coerced3 !== undefined);
768
- else if (dataType3 == 'number' || dataType3 == 'boolean') coerced3 = '' + data3;
769
- else if (data3 === null) coerced3 = '';
770
- else {
771
- validate.errors = [{
772
- keyword: 'type',
773
- dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\'].name',
774
- schemaPath: '#/properties/constraints/additionalProperties/properties/name/type',
775
- params: {
776
- type: 'string'
777
- },
778
- message: 'should be string'
779
- }];
780
- return false;
781
- }
782
- if (coerced3 !== undefined) {
783
- data3 = coerced3;
784
- data2['name'] = coerced3;
785
- }
786
- }
787
- var valid3 = errors === errs_3;
788
- }
789
- if (valid3) {
790
- if (valid3) {
791
- if (valid3) {
792
- if (valid3) {}
793
- }
794
- }
795
- }
796
- }
797
- if (errs__2 == errors) {}
702
+ var missing1;
703
+ if (((data1.storage === undefined) && (missing1 = '.storage')) || ((data1.deriveVersion === undefined) && (missing1 = '.deriveVersion'))) {
704
+ validate.errors = [{
705
+ keyword: 'required',
706
+ dataPath: (dataPath || '') + '.versioning',
707
+ schemaPath: '#/properties/versioning/required',
708
+ params: {
709
+ missingProperty: '' + missing1 + ''
710
+ },
711
+ message: 'should have required property \'' + missing1 + '\''
712
+ }];
713
+ return false;
714
+ } else {
715
+ var errs__1 = errors;
716
+ var valid2 = true;
717
+ for (var key1 in data1) {
718
+ var isAdditional1 = !(false || key1 == 'storage' || key1 == 'deriveVersion');
719
+ if (isAdditional1) {}
720
+ }
721
+ if (valid2) {
722
+ if (valid2) {
723
+ if (valid2) {}
798
724
  }
799
- } else {
800
- validate.errors = [{
801
- keyword: 'type',
802
- dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
803
- schemaPath: '#/properties/constraints/additionalProperties/type',
804
- params: {
805
- type: 'object'
806
- },
807
- message: 'should be object'
808
- }];
809
- return false;
810
725
  }
811
- if (errors === errs_2) {}
812
- var valid2 = errors === errs_2;
813
- if (!valid2) break;
726
+ if (errs__1 == errors) {}
814
727
  }
815
- if (valid2) {}
816
- if (errs__1 == errors) {}
817
728
  } else {
818
729
  validate.errors = [{
819
730
  keyword: 'type',
820
- dataPath: (dataPath || '') + '.constraints',
821
- schemaPath: '#/properties/constraints/type',
731
+ dataPath: (dataPath || '') + '.versioning',
732
+ schemaPath: '#/properties/versioning/type',
822
733
  params: {
823
734
  type: 'object'
824
735
  },
@@ -829,7 +740,124 @@ var validate = (function() {
829
740
  if (errors === errs_1) {}
830
741
  var valid1 = errors === errs_1;
831
742
  }
832
- if (valid1) {}
743
+ if (valid1) {
744
+ var data1 = data.constraints;
745
+ if (data1 === undefined) {
746
+ valid1 = true;
747
+ } else {
748
+ var errs_1 = errors;
749
+ if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
750
+ var errs__1 = errors;
751
+ var valid2 = true;
752
+ for (var key1 in data1) {
753
+ var data2 = data1[key1];
754
+ var errs_2 = errors;
755
+ if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
756
+ var missing2;
757
+ if (((data2.storage === undefined) && (missing2 = '.storage')) || ((data2.validate === undefined) && (missing2 = '.validate')) || ((data2.deriveConstraint === undefined) && (missing2 = '.deriveConstraint'))) {
758
+ validate.errors = [{
759
+ keyword: 'required',
760
+ dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
761
+ schemaPath: '#/properties/constraints/additionalProperties/required',
762
+ params: {
763
+ missingProperty: '' + missing2 + ''
764
+ },
765
+ message: 'should have required property \'' + missing2 + '\''
766
+ }];
767
+ return false;
768
+ } else {
769
+ var errs__2 = errors;
770
+ var valid3 = true;
771
+ for (var key2 in data2) {
772
+ var isAdditional2 = !(false || key2 == 'name' || key2 == 'storage' || key2 == 'validate' || key2 == 'deriveConstraint');
773
+ if (isAdditional2) {}
774
+ }
775
+ if (valid3) {
776
+ var data3 = data2.name;
777
+ if (data3 === undefined) {
778
+ valid3 = false;
779
+ validate.errors = [{
780
+ keyword: 'required',
781
+ dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
782
+ schemaPath: '#/properties/constraints/additionalProperties/required',
783
+ params: {
784
+ missingProperty: 'name'
785
+ },
786
+ message: 'should have required property \'name\''
787
+ }];
788
+ return false;
789
+ } else {
790
+ var errs_3 = errors;
791
+ if (typeof data3 !== "string") {
792
+ var dataType3 = typeof data3;
793
+ var coerced3 = undefined;
794
+ if (coerced3 !== undefined);
795
+ else if (dataType3 == 'number' || dataType3 == 'boolean') coerced3 = '' + data3;
796
+ else if (data3 === null) coerced3 = '';
797
+ else {
798
+ validate.errors = [{
799
+ keyword: 'type',
800
+ dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\'].name',
801
+ schemaPath: '#/properties/constraints/additionalProperties/properties/name/type',
802
+ params: {
803
+ type: 'string'
804
+ },
805
+ message: 'should be string'
806
+ }];
807
+ return false;
808
+ }
809
+ if (coerced3 !== undefined) {
810
+ data3 = coerced3;
811
+ data2['name'] = coerced3;
812
+ }
813
+ }
814
+ var valid3 = errors === errs_3;
815
+ }
816
+ if (valid3) {
817
+ if (valid3) {
818
+ if (valid3) {
819
+ if (valid3) {}
820
+ }
821
+ }
822
+ }
823
+ }
824
+ if (errs__2 == errors) {}
825
+ }
826
+ } else {
827
+ validate.errors = [{
828
+ keyword: 'type',
829
+ dataPath: (dataPath || '') + '.constraints[\'' + key1 + '\']',
830
+ schemaPath: '#/properties/constraints/additionalProperties/type',
831
+ params: {
832
+ type: 'object'
833
+ },
834
+ message: 'should be object'
835
+ }];
836
+ return false;
837
+ }
838
+ if (errors === errs_2) {}
839
+ var valid2 = errors === errs_2;
840
+ if (!valid2) break;
841
+ }
842
+ if (valid2) {}
843
+ if (errs__1 == errors) {}
844
+ } else {
845
+ validate.errors = [{
846
+ keyword: 'type',
847
+ dataPath: (dataPath || '') + '.constraints',
848
+ schemaPath: '#/properties/constraints/type',
849
+ params: {
850
+ type: 'object'
851
+ },
852
+ message: 'should be object'
853
+ }];
854
+ return false;
855
+ }
856
+ if (errors === errs_1) {}
857
+ var valid1 = errors === errs_1;
858
+ }
859
+ if (valid1) {}
860
+ }
833
861
  }
834
862
  }
835
863
  }
@@ -884,6 +912,10 @@ validate.schema = {
884
912
  "default": 0,
885
913
  "nullable": true
886
914
  },
915
+ "requestTimeout": {
916
+ "type": "integer",
917
+ "default": 0
918
+ },
887
919
  "bodyLimit": {
888
920
  "type": "integer",
889
921
  "default": 1048576
@@ -993,4 +1025,4 @@ function customRule0 (schemaParamValue, validatedParamValue, validationSchemaObj
993
1025
  return true
994
1026
  }
995
1027
 
996
- module.exports.defaultInitOptions = {"connectionTimeout":0,"keepAliveTimeout":5000,"maxRequestsPerSocket":0,"bodyLimit":1048576,"caseSensitive":true,"disableRequestLogging":false,"jsonShorthand":true,"ignoreTrailingSlash":false,"maxParamLength":100,"onProtoPoisoning":"error","onConstructorPoisoning":"error","pluginTimeout":10000,"requestIdHeader":"request-id","requestIdLogLabel":"reqId","http2SessionTimeout":5000}
1028
+ module.exports.defaultInitOptions = {"connectionTimeout":0,"keepAliveTimeout":5000,"maxRequestsPerSocket":0,"requestTimeout":0,"bodyLimit":1048576,"caseSensitive":true,"disableRequestLogging":false,"jsonShorthand":true,"ignoreTrailingSlash":false,"maxParamLength":100,"onProtoPoisoning":"error","onConstructorPoisoning":"error","pluginTimeout":10000,"requestIdHeader":"request-id","requestIdLogLabel":"reqId","http2SessionTimeout":5000}