fastify 4.25.2 → 4.26.1

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 (55) hide show
  1. package/EXPENSE_POLICY.md +105 -0
  2. package/GOVERNANCE.md +2 -103
  3. package/LICENSE +1 -1
  4. package/README.md +13 -9
  5. package/SECURITY.md +2 -157
  6. package/SPONSORS.md +20 -0
  7. package/build/build-validation.js +3 -1
  8. package/docs/Guides/Ecosystem.md +29 -9
  9. package/docs/Guides/Getting-Started.md +16 -3
  10. package/docs/Guides/Style-Guide.md +7 -7
  11. package/docs/Reference/Decorators.md +1 -1
  12. package/docs/Reference/Errors.md +63 -1
  13. package/docs/Reference/Hooks.md +1 -1
  14. package/docs/Reference/Logging.md +3 -3
  15. package/docs/Reference/Reply.md +70 -1
  16. package/docs/Reference/Server.md +90 -0
  17. package/docs/Reference/Warnings.md +17 -2
  18. package/fastify.d.ts +3 -2
  19. package/fastify.js +25 -7
  20. package/lib/configValidator.js +62 -33
  21. package/lib/contentTypeParser.js +9 -2
  22. package/lib/error-handler.js +1 -1
  23. package/lib/error-serializer.js +30 -29
  24. package/lib/errors.js +6 -1
  25. package/lib/fourOhFour.js +4 -3
  26. package/lib/hooks.js +1 -5
  27. package/lib/reply.js +68 -10
  28. package/lib/reqIdGenFactory.js +5 -0
  29. package/lib/route.js +22 -6
  30. package/lib/schema-controller.js +37 -4
  31. package/lib/symbols.js +1 -0
  32. package/lib/warnings.js +6 -0
  33. package/package.json +18 -6
  34. package/test/async_hooks.test.js +69 -0
  35. package/test/findRoute.test.js +135 -0
  36. package/test/genReqId.test.js +392 -0
  37. package/test/hooks.on-listen.test.js +66 -14
  38. package/test/hooks.on-ready.test.js +1 -1
  39. package/test/internals/errors.test.js +17 -7
  40. package/test/internals/initialConfig.test.js +7 -3
  41. package/test/internals/reply.test.js +80 -5
  42. package/test/plugin.4.test.js +3 -3
  43. package/test/pretty-print.test.js +1 -1
  44. package/test/schema-serialization.test.js +41 -0
  45. package/test/schema-validation.test.js +115 -6
  46. package/test/serialize-response.test.js +187 -0
  47. package/test/types/instance.test-d.ts +14 -1
  48. package/test/types/reply.test-d.ts +4 -2
  49. package/test/types/request.test-d.ts +1 -1
  50. package/test/types/route.test-d.ts +15 -1
  51. package/test/useSemicolonDelimiter.test.js +113 -0
  52. package/test/web-api.test.js +208 -0
  53. package/types/instance.d.ts +23 -10
  54. package/types/reply.d.ts +4 -0
  55. package/types/request.d.ts +5 -4
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { Readable } = require('node:stream')
4
4
  const { test } = require('tap')
5
+ const fp = require('fastify-plugin')
5
6
  const Fastify = require('..')
6
7
 
7
8
  test('Should accept a custom genReqId function', t => {
@@ -72,3 +73,394 @@ test('Custom genReqId function gets raw request as argument', t => {
72
73
  })
73
74
  })
74
75
  })
76
+
77
+ test('Should accept option to set genReqId with setGenReqId option', t => {
78
+ t.plan(9)
79
+
80
+ const fastify = Fastify({
81
+ genReqId: function (req) {
82
+ return 'base'
83
+ }
84
+ })
85
+
86
+ fastify.register(function (instance, opts, next) {
87
+ instance.setGenReqId(function (req) {
88
+ return 'foo'
89
+ })
90
+ instance.get('/', (req, reply) => {
91
+ t.ok(req.id)
92
+ reply.send({ id: req.id })
93
+ })
94
+ next()
95
+ }, { prefix: 'foo' })
96
+
97
+ fastify.register(function (instance, opts, next) {
98
+ instance.setGenReqId(function (req) {
99
+ return 'bar'
100
+ })
101
+ instance.get('/', (req, reply) => {
102
+ t.ok(req.id)
103
+ reply.send({ id: req.id })
104
+ })
105
+ next()
106
+ }, { prefix: 'bar' })
107
+
108
+ fastify.get('/', (req, reply) => {
109
+ t.ok(req.id)
110
+ reply.send({ id: req.id })
111
+ })
112
+
113
+ fastify.inject({
114
+ method: 'GET',
115
+ url: '/'
116
+ }, (err, res) => {
117
+ t.error(err)
118
+ const payload = JSON.parse(res.payload)
119
+ t.equal(payload.id, 'base')
120
+ fastify.close()
121
+ })
122
+
123
+ fastify.inject({
124
+ method: 'GET',
125
+ url: '/foo'
126
+ }, (err, res) => {
127
+ t.error(err)
128
+ const payload = JSON.parse(res.payload)
129
+ t.equal(payload.id, 'foo')
130
+ fastify.close()
131
+ })
132
+
133
+ fastify.inject({
134
+ method: 'GET',
135
+ url: '/bar'
136
+ }, (err, res) => {
137
+ t.error(err)
138
+ const payload = JSON.parse(res.payload)
139
+ t.equal(payload.id, 'bar')
140
+ fastify.close()
141
+ })
142
+ })
143
+
144
+ test('Should encapsulate setGenReqId', t => {
145
+ t.plan(12)
146
+
147
+ const fastify = Fastify({
148
+ genReqId: function (req) {
149
+ return 'base'
150
+ }
151
+ })
152
+
153
+ const bazInstance = function (instance, opts, next) {
154
+ instance.register(barInstance, { prefix: 'baz' })
155
+
156
+ instance.setGenReqId(function (req) {
157
+ return 'baz'
158
+ })
159
+ instance.get('/', (req, reply) => {
160
+ t.ok(req.id)
161
+ reply.send({ id: req.id })
162
+ })
163
+ next()
164
+ }
165
+
166
+ const barInstance = function (instance, opts, next) {
167
+ instance.setGenReqId(function (req) {
168
+ return 'bar'
169
+ })
170
+ instance.get('/', (req, reply) => {
171
+ t.ok(req.id)
172
+ reply.send({ id: req.id })
173
+ })
174
+ next()
175
+ }
176
+
177
+ const fooInstance = function (instance, opts, next) {
178
+ instance.register(bazInstance, { prefix: 'baz' })
179
+ instance.register(barInstance, { prefix: 'bar' })
180
+
181
+ instance.setGenReqId(function (req) {
182
+ return 'foo'
183
+ })
184
+
185
+ instance.get('/', (req, reply) => {
186
+ t.ok(req.id)
187
+ reply.send({ id: req.id })
188
+ })
189
+ next()
190
+ }
191
+
192
+ fastify.register(fooInstance, { prefix: 'foo' })
193
+
194
+ fastify.get('/', (req, reply) => {
195
+ t.ok(req.id)
196
+ reply.send({ id: req.id })
197
+ })
198
+
199
+ fastify.inject({
200
+ method: 'GET',
201
+ url: '/'
202
+ }, (err, res) => {
203
+ t.error(err)
204
+ const payload = JSON.parse(res.payload)
205
+ t.equal(payload.id, 'base')
206
+ fastify.close()
207
+ })
208
+
209
+ fastify.inject({
210
+ method: 'GET',
211
+ url: '/foo'
212
+ }, (err, res) => {
213
+ t.error(err)
214
+ const payload = JSON.parse(res.payload)
215
+ t.equal(payload.id, 'foo')
216
+ fastify.close()
217
+ })
218
+
219
+ fastify.inject({
220
+ method: 'GET',
221
+ url: '/foo/bar'
222
+ }, (err, res) => {
223
+ t.error(err)
224
+ const payload = JSON.parse(res.payload)
225
+ t.equal(payload.id, 'bar')
226
+ fastify.close()
227
+ })
228
+
229
+ fastify.inject({
230
+ method: 'GET',
231
+ url: '/foo/baz'
232
+ }, (err, res) => {
233
+ t.error(err)
234
+ const payload = JSON.parse(res.payload)
235
+ t.equal(payload.id, 'baz')
236
+ fastify.close()
237
+ })
238
+ })
239
+
240
+ test('Should encapsulate setGenReqId', t => {
241
+ t.plan(12)
242
+
243
+ const fastify = Fastify({
244
+ genReqId: function (req) {
245
+ return 'base'
246
+ }
247
+ })
248
+
249
+ const bazInstance = function (instance, opts, next) {
250
+ instance.register(barInstance, { prefix: 'baz' })
251
+
252
+ instance.setGenReqId(function (req) {
253
+ return 'baz'
254
+ })
255
+ instance.get('/', (req, reply) => {
256
+ t.ok(req.id)
257
+ reply.send({ id: req.id })
258
+ })
259
+ next()
260
+ }
261
+
262
+ const barInstance = function (instance, opts, next) {
263
+ instance.setGenReqId(function (req) {
264
+ return 'bar'
265
+ })
266
+ instance.get('/', (req, reply) => {
267
+ t.ok(req.id)
268
+ reply.send({ id: req.id })
269
+ })
270
+ next()
271
+ }
272
+
273
+ const fooInstance = function (instance, opts, next) {
274
+ instance.register(bazInstance, { prefix: 'baz' })
275
+ instance.register(barInstance, { prefix: 'bar' })
276
+
277
+ instance.setGenReqId(function (req) {
278
+ return 'foo'
279
+ })
280
+
281
+ instance.get('/', (req, reply) => {
282
+ t.ok(req.id)
283
+ reply.send({ id: req.id })
284
+ })
285
+ next()
286
+ }
287
+
288
+ fastify.register(fooInstance, { prefix: 'foo' })
289
+
290
+ fastify.get('/', (req, reply) => {
291
+ t.ok(req.id)
292
+ reply.send({ id: req.id })
293
+ })
294
+
295
+ fastify.inject({
296
+ method: 'GET',
297
+ url: '/'
298
+ }, (err, res) => {
299
+ t.error(err)
300
+ const payload = JSON.parse(res.payload)
301
+ t.equal(payload.id, 'base')
302
+ fastify.close()
303
+ })
304
+
305
+ fastify.inject({
306
+ method: 'GET',
307
+ url: '/foo'
308
+ }, (err, res) => {
309
+ t.error(err)
310
+ const payload = JSON.parse(res.payload)
311
+ t.equal(payload.id, 'foo')
312
+ fastify.close()
313
+ })
314
+
315
+ fastify.inject({
316
+ method: 'GET',
317
+ url: '/foo/bar'
318
+ }, (err, res) => {
319
+ t.error(err)
320
+ const payload = JSON.parse(res.payload)
321
+ t.equal(payload.id, 'bar')
322
+ fastify.close()
323
+ })
324
+
325
+ fastify.inject({
326
+ method: 'GET',
327
+ url: '/foo/baz'
328
+ }, (err, res) => {
329
+ t.error(err)
330
+ const payload = JSON.parse(res.payload)
331
+ t.equal(payload.id, 'baz')
332
+ fastify.close()
333
+ })
334
+ })
335
+
336
+ test('Should not alter parent of genReqId', t => {
337
+ t.plan(6)
338
+
339
+ const fastify = Fastify()
340
+
341
+ const fooInstance = function (instance, opts, next) {
342
+ instance.setGenReqId(function (req) {
343
+ return 'foo'
344
+ })
345
+
346
+ instance.get('/', (req, reply) => {
347
+ t.ok(req.id)
348
+ reply.send({ id: req.id })
349
+ })
350
+ next()
351
+ }
352
+
353
+ fastify.register(fooInstance, { prefix: 'foo' })
354
+
355
+ fastify.get('/', (req, reply) => {
356
+ t.ok(req.id)
357
+ reply.send({ id: req.id })
358
+ })
359
+
360
+ fastify.inject({
361
+ method: 'GET',
362
+ url: '/'
363
+ }, (err, res) => {
364
+ t.error(err)
365
+ const payload = JSON.parse(res.payload)
366
+ t.equal(payload.id, 'req-1')
367
+ fastify.close()
368
+ })
369
+
370
+ fastify.inject({
371
+ method: 'GET',
372
+ url: '/foo'
373
+ }, (err, res) => {
374
+ t.error(err)
375
+ const payload = JSON.parse(res.payload)
376
+ t.equal(payload.id, 'foo')
377
+ fastify.close()
378
+ })
379
+ })
380
+
381
+ test('Should have child instance user parent genReqId', t => {
382
+ t.plan(6)
383
+
384
+ const fastify = Fastify({
385
+ genReqId: function (req) {
386
+ return 'foo'
387
+ }
388
+ })
389
+
390
+ const fooInstance = function (instance, opts, next) {
391
+ instance.get('/', (req, reply) => {
392
+ t.ok(req.id)
393
+ reply.send({ id: req.id })
394
+ })
395
+ next()
396
+ }
397
+
398
+ fastify.register(fooInstance, { prefix: 'foo' })
399
+
400
+ fastify.get('/', (req, reply) => {
401
+ t.ok(req.id)
402
+ reply.send({ id: req.id })
403
+ })
404
+
405
+ fastify.inject({
406
+ method: 'GET',
407
+ url: '/'
408
+ }, (err, res) => {
409
+ t.error(err)
410
+ const payload = JSON.parse(res.payload)
411
+ t.equal(payload.id, 'foo')
412
+ fastify.close()
413
+ })
414
+
415
+ fastify.inject({
416
+ method: 'GET',
417
+ url: '/foo'
418
+ }, (err, res) => {
419
+ t.error(err)
420
+ const payload = JSON.parse(res.payload)
421
+ t.equal(payload.id, 'foo')
422
+ fastify.close()
423
+ })
424
+ })
425
+
426
+ test('genReqId set on root scope when using fastify-plugin', t => {
427
+ t.plan(6)
428
+
429
+ const fastify = Fastify()
430
+
431
+ fastify.register(fp(function (fastify, options, done) {
432
+ fastify.setGenReqId(function (req) {
433
+ return 'not-encapsulated'
434
+ })
435
+ fastify.get('/not-encapsulated-1', (req, reply) => {
436
+ t.ok(req.id)
437
+ reply.send({ id: req.id })
438
+ })
439
+ done()
440
+ }))
441
+
442
+ fastify.get('/not-encapsulated-2', (req, reply) => {
443
+ t.ok(req.id)
444
+ reply.send({ id: req.id })
445
+ })
446
+
447
+ fastify.inject({
448
+ method: 'GET',
449
+ url: '/not-encapsulated-1'
450
+ }, (err, res) => {
451
+ t.error(err)
452
+ const payload = JSON.parse(res.payload)
453
+ t.equal(payload.id, 'not-encapsulated')
454
+ fastify.close()
455
+ })
456
+
457
+ fastify.inject({
458
+ method: 'GET',
459
+ url: '/not-encapsulated-2'
460
+ }, (err, res) => {
461
+ t.error(err)
462
+ const payload = JSON.parse(res.payload)
463
+ t.equal(payload.id, 'not-encapsulated')
464
+ fastify.close()
465
+ })
466
+ })
@@ -5,9 +5,7 @@ const Fastify = require('../fastify')
5
5
  const fp = require('fastify-plugin')
6
6
  const split = require('split2')
7
7
  const helper = require('./helper')
8
-
9
- // fix citgm @aix72-ppc64
10
- const LISTEN_READYNESS = process.env.CITGM ? 250 : 50
8
+ const { kState } = require('../lib/symbols')
11
9
 
12
10
  let localhost
13
11
  before(async function () {
@@ -274,8 +272,8 @@ test('localhost Register onListen hook after a plugin inside a plugin should log
274
272
  })
275
273
  })
276
274
 
277
- test('localhost onListen encapsulation should be called in order', t => {
278
- t.plan(6)
275
+ test('localhost onListen encapsulation should be called in order', async t => {
276
+ t.plan(8)
279
277
  const fastify = Fastify()
280
278
  t.teardown(fastify.close.bind(fastify))
281
279
 
@@ -287,20 +285,75 @@ test('localhost onListen encapsulation should be called in order', t => {
287
285
  done()
288
286
  })
289
287
 
290
- fastify.register(async (childOne, o) => {
288
+ await fastify.register(async (childOne, o) => {
291
289
  childOne.addHook('onListen', function (done) {
292
290
  t.equal(++order, 2, 'called in childOne')
293
291
  t.equal(this.pluginName, childOne.pluginName, 'the this binding is the right instance')
294
292
  done()
295
293
  })
296
- childOne.register(async (childTwo, o) => {
294
+
295
+ await childOne.register(async (childTwo, o) => {
297
296
  childTwo.addHook('onListen', async function () {
298
297
  t.equal(++order, 3, 'called in childTwo')
299
298
  t.equal(this.pluginName, childTwo.pluginName, 'the this binding is the right instance')
300
299
  })
301
300
  })
301
+
302
+ await childOne.register(async (childTwoPeer, o) => {
303
+ childTwoPeer.addHook('onListen', async function () {
304
+ t.equal(++order, 4, 'called second in childTwo')
305
+ t.equal(this.pluginName, childTwoPeer.pluginName, 'the this binding is the right instance')
306
+ })
307
+ })
302
308
  })
303
- fastify.listen({
309
+ await fastify.listen({
310
+ host: 'localhost',
311
+ port: 0
312
+ })
313
+ })
314
+
315
+ test('localhost onListen encapsulation with only nested hook', async t => {
316
+ t.plan(1)
317
+ const fastify = Fastify()
318
+ t.teardown(fastify.close.bind(fastify))
319
+
320
+ await fastify.register(async (child) => {
321
+ await child.register(async (child2) => {
322
+ child2.addHook('onListen', function (done) {
323
+ t.pass()
324
+ done()
325
+ })
326
+ })
327
+ })
328
+
329
+ await fastify.listen({
330
+ host: 'localhost',
331
+ port: 0
332
+ })
333
+ })
334
+
335
+ test('localhost onListen peer encapsulations with only nested hooks', async t => {
336
+ t.plan(2)
337
+ const fastify = Fastify()
338
+ t.teardown(fastify.close.bind(fastify))
339
+
340
+ await fastify.register(async (child) => {
341
+ await child.register(async (child2) => {
342
+ child2.addHook('onListen', function (done) {
343
+ t.pass()
344
+ done()
345
+ })
346
+ })
347
+
348
+ await child.register(async (child2) => {
349
+ child2.addHook('onListen', function (done) {
350
+ t.pass()
351
+ done()
352
+ })
353
+ })
354
+ })
355
+
356
+ await fastify.listen({
304
357
  host: 'localhost',
305
358
  port: 0
306
359
  })
@@ -1056,36 +1109,35 @@ test('async onListen does not need to be awaited', t => {
1056
1109
 
1057
1110
  test('onListen hooks do not block /1', t => {
1058
1111
  t.plan(2)
1112
+
1059
1113
  const fastify = Fastify()
1060
1114
  t.teardown(fastify.close.bind(fastify))
1061
1115
 
1062
1116
  fastify.addHook('onListen', function (done) {
1063
- setTimeout(done, 500)
1117
+ t.equal(fastify[kState].listening, true)
1118
+ done()
1064
1119
  })
1065
1120
 
1066
- const startDate = new Date()
1067
1121
  fastify.listen({
1068
1122
  host: 'localhost',
1069
1123
  port: 0
1070
1124
  }, err => {
1071
1125
  t.error(err)
1072
- t.ok(new Date() - startDate < LISTEN_READYNESS)
1073
1126
  })
1074
1127
  })
1075
1128
 
1076
1129
  test('onListen hooks do not block /2', async t => {
1077
1130
  t.plan(1)
1131
+
1078
1132
  const fastify = Fastify()
1079
1133
  t.teardown(fastify.close.bind(fastify))
1080
1134
 
1081
1135
  fastify.addHook('onListen', async function () {
1082
- await new Promise(resolve => setTimeout(resolve, 500))
1136
+ t.equal(fastify[kState].listening, true)
1083
1137
  })
1084
1138
 
1085
- const startDate = new Date()
1086
1139
  await fastify.listen({
1087
1140
  host: 'localhost',
1088
1141
  port: 0
1089
1142
  })
1090
- t.ok(new Date() - startDate < LISTEN_READYNESS)
1091
1143
  })
@@ -295,7 +295,7 @@ t.test('onReady cannot add lifecycle hooks', t => {
295
295
  t.ok(error)
296
296
  t.equal(error.message, 'Root plugin has already booted')
297
297
  // TODO: look where the error pops up
298
- t.equal(error.code, 'AVV_ERR_PLUGIN_NOT_VALID')
298
+ t.equal(error.code, 'AVV_ERR_ROOT_PLG_BOOTED')
299
299
  done(error)
300
300
  }
301
301
  })
@@ -5,7 +5,7 @@ const errors = require('../../lib/errors')
5
5
  const { readFileSync } = require('node:fs')
6
6
  const { resolve } = require('node:path')
7
7
 
8
- test('should expose 78 errors', t => {
8
+ test('should expose 79 errors', t => {
9
9
  t.plan(1)
10
10
  const exportedKeys = Object.keys(errors)
11
11
  let counter = 0
@@ -14,11 +14,11 @@ test('should expose 78 errors', t => {
14
14
  counter++
15
15
  }
16
16
  }
17
- t.equal(counter, 78)
17
+ t.equal(counter, 79)
18
18
  })
19
19
 
20
20
  test('ensure name and codes of Errors are identical', t => {
21
- t.plan(78)
21
+ t.plan(79)
22
22
  const exportedKeys = Object.keys(errors)
23
23
  for (const key of exportedKeys) {
24
24
  if (errors[key].name === 'FastifyError') {
@@ -337,6 +337,16 @@ test('FST_ERR_REP_INVALID_PAYLOAD_TYPE', t => {
337
337
  t.ok(error instanceof TypeError)
338
338
  })
339
339
 
340
+ test('FST_ERR_REP_RESPONSE_BODY_CONSUMED', t => {
341
+ t.plan(5)
342
+ const error = new errors.FST_ERR_REP_RESPONSE_BODY_CONSUMED()
343
+ t.equal(error.name, 'FastifyError')
344
+ t.equal(error.code, 'FST_ERR_REP_RESPONSE_BODY_CONSUMED')
345
+ t.equal(error.message, 'Response.body is already consumed.')
346
+ t.equal(error.statusCode, 500)
347
+ t.ok(error instanceof Error)
348
+ })
349
+
340
350
  test('FST_ERR_REP_ALREADY_SENT', t => {
341
351
  t.plan(5)
342
352
  const error = new errors.FST_ERR_REP_ALREADY_SENT('/hello', 'GET')
@@ -818,7 +828,7 @@ test('FST_ERR_LISTEN_OPTIONS_INVALID', t => {
818
828
  })
819
829
 
820
830
  test('Ensure that all errors are in Errors.md TOC', t => {
821
- t.plan(78)
831
+ t.plan(79)
822
832
  const errorsMd = readFileSync(resolve(__dirname, '../../docs/Reference/Errors.md'), 'utf8')
823
833
 
824
834
  const exportedKeys = Object.keys(errors)
@@ -830,7 +840,7 @@ test('Ensure that all errors are in Errors.md TOC', t => {
830
840
  })
831
841
 
832
842
  test('Ensure that non-existing errors are not in Errors.md TOC', t => {
833
- t.plan(78)
843
+ t.plan(79)
834
844
  const errorsMd = readFileSync(resolve(__dirname, '../../docs/Reference/Errors.md'), 'utf8')
835
845
 
836
846
  const matchRE = / {4}- \[([A-Z0-9_]+)\]\(#[a-z0-9_]+\)/g
@@ -843,7 +853,7 @@ test('Ensure that non-existing errors are not in Errors.md TOC', t => {
843
853
  })
844
854
 
845
855
  test('Ensure that all errors are in Errors.md documented', t => {
846
- t.plan(78)
856
+ t.plan(79)
847
857
  const errorsMd = readFileSync(resolve(__dirname, '../../docs/Reference/Errors.md'), 'utf8')
848
858
 
849
859
  const exportedKeys = Object.keys(errors)
@@ -855,7 +865,7 @@ test('Ensure that all errors are in Errors.md documented', t => {
855
865
  })
856
866
 
857
867
  test('Ensure that non-existing errors are not in Errors.md documented', t => {
858
- t.plan(78)
868
+ t.plan(79)
859
869
  const errorsMd = readFileSync(resolve(__dirname, '../../docs/Reference/Errors.md'), 'utf8')
860
870
 
861
871
  const matchRE = /<a id="[0-9a-zA-Z_]+">([0-9a-zA-Z_]+)<\/a>/g
@@ -48,14 +48,15 @@ test('without options passed to Fastify, initialConfig should expose default val
48
48
  requestIdHeader: 'request-id',
49
49
  requestIdLogLabel: 'reqId',
50
50
  http2SessionTimeout: 72000,
51
- exposeHeadRoutes: true
51
+ exposeHeadRoutes: true,
52
+ useSemicolonDelimiter: true
52
53
  }
53
54
 
54
55
  t.same(Fastify().initialConfig, fastifyDefaultOptions)
55
56
  })
56
57
 
57
58
  test('Fastify.initialConfig should expose all options', t => {
58
- t.plan(21)
59
+ t.plan(22)
59
60
 
60
61
  const serverFactory = (handler, opts) => {
61
62
  const server = http.createServer((req, res) => {
@@ -99,6 +100,7 @@ test('Fastify.initialConfig should expose all options', t => {
99
100
  allowUnsafeRegex: false,
100
101
  requestIdHeader: 'request-id-alt',
101
102
  pluginTimeout: 20000,
103
+ useSemicolonDelimiter: false,
102
104
  querystringParser: str => str,
103
105
  genReqId: function (req) {
104
106
  return reqId++
@@ -123,6 +125,7 @@ test('Fastify.initialConfig should expose all options', t => {
123
125
  t.equal(fastify.initialConfig.bodyLimit, 1049600)
124
126
  t.equal(fastify.initialConfig.onProtoPoisoning, 'remove')
125
127
  t.equal(fastify.initialConfig.caseSensitive, true)
128
+ t.equal(fastify.initialConfig.useSemicolonDelimiter, false)
126
129
  t.equal(fastify.initialConfig.allowUnsafeRegex, false)
127
130
  t.equal(fastify.initialConfig.requestIdHeader, 'request-id-alt')
128
131
  t.equal(fastify.initialConfig.pluginTimeout, 20000)
@@ -285,7 +288,8 @@ test('Should not have issues when passing stream options to Pino.js', t => {
285
288
  requestIdHeader: 'request-id',
286
289
  requestIdLogLabel: 'reqId',
287
290
  http2SessionTimeout: 72000,
288
- exposeHeadRoutes: true
291
+ exposeHeadRoutes: true,
292
+ useSemicolonDelimiter: true
289
293
  })
290
294
  } catch (error) {
291
295
  t.fail()