fastify 4.17.0 → 4.18.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 (49) hide show
  1. package/GOVERNANCE.md +2 -2
  2. package/README.md +13 -10
  3. package/docs/Guides/Ecosystem.md +6 -0
  4. package/docs/Guides/Serverless.md +12 -1
  5. package/docs/Reference/Errors.md +5 -0
  6. package/docs/Reference/LTS.md +5 -5
  7. package/docs/Reference/Lifecycle.md +3 -0
  8. package/docs/Reference/Logging.md +34 -1
  9. package/docs/Reference/Reply.md +19 -0
  10. package/docs/Reference/Request.md +1 -1
  11. package/docs/Reference/Server.md +20 -2
  12. package/docs/Reference/Validation-and-Serialization.md +3 -2
  13. package/examples/benchmark/body.json +3 -0
  14. package/fastify.d.ts +6 -1
  15. package/fastify.js +17 -12
  16. package/lib/contentTypeParser.js +3 -1
  17. package/lib/errors.js +5 -0
  18. package/lib/handleRequest.js +15 -4
  19. package/lib/reply.js +3 -2
  20. package/lib/route.js +14 -3
  21. package/lib/schemas.js +18 -21
  22. package/lib/server.js +9 -4
  23. package/lib/validation.js +98 -16
  24. package/package.json +33 -33
  25. package/test/custom-parser.0.test.js +777 -0
  26. package/test/{custom-parser.test.js → custom-parser.1.test.js} +1 -742
  27. package/test/fastify-instance.test.js +39 -0
  28. package/test/hooks-async.test.js +154 -0
  29. package/test/hooks.test.js +29 -29
  30. package/test/internals/reply.test.js +114 -45
  31. package/test/internals/validation.test.js +58 -0
  32. package/test/reply-error.test.js +7 -7
  33. package/test/request-error.test.js +3 -0
  34. package/test/route-hooks.test.js +38 -0
  35. package/test/route.test.js +192 -74
  36. package/test/schema-special-usage.test.js +569 -0
  37. package/test/types/fastify.test-d.ts +4 -1
  38. package/test/types/instance.test-d.ts +1 -0
  39. package/test/types/logger.test-d.ts +10 -4
  40. package/test/types/reply.test-d.ts +4 -1
  41. package/test/types/route.test-d.ts +12 -0
  42. package/test/url-rewriting.test.js +3 -0
  43. package/types/.eslintrc.json +1 -1
  44. package/types/instance.d.ts +1 -1
  45. package/types/logger.d.ts +10 -1
  46. package/types/reply.d.ts +7 -1
  47. package/types/type-provider.d.ts +0 -1
  48. package/types/utils.d.ts +3 -1
  49. /package/types/{tsconfig.json → tsconfig.eslint.json} +0 -0
@@ -1,10 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const fs = require('fs')
4
3
  const t = require('tap')
5
4
  const test = t.test
6
5
  const sget = require('simple-get').concat
7
- const Fastify = require('..')
6
+ const Fastify = require('../fastify')
8
7
 
9
8
  const jsonParser = require('fast-json-body')
10
9
 
@@ -36,746 +35,6 @@ function getUrl (app) {
36
35
 
37
36
  process.removeAllListeners('warning')
38
37
 
39
- test('contentTypeParser method should exist', t => {
40
- t.plan(1)
41
- const fastify = Fastify()
42
- t.ok(fastify.addContentTypeParser)
43
- })
44
-
45
- test('contentTypeParser should add a custom parser', t => {
46
- t.plan(3)
47
- const fastify = Fastify()
48
-
49
- fastify.post('/', (req, reply) => {
50
- reply.send(req.body)
51
- })
52
-
53
- fastify.options('/', (req, reply) => {
54
- reply.send(req.body)
55
- })
56
-
57
- fastify.addContentTypeParser('application/jsoff', function (req, payload, done) {
58
- jsonParser(payload, function (err, body) {
59
- done(err, body)
60
- })
61
- })
62
-
63
- fastify.listen({ port: 0 }, err => {
64
- t.error(err)
65
-
66
- t.teardown(() => fastify.close())
67
-
68
- t.test('in POST', t => {
69
- t.plan(3)
70
-
71
- sget({
72
- method: 'POST',
73
- url: getUrl(fastify),
74
- body: '{"hello":"world"}',
75
- headers: {
76
- 'Content-Type': 'application/jsoff'
77
- }
78
- }, (err, response, body) => {
79
- t.error(err)
80
- t.equal(response.statusCode, 200)
81
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
82
- })
83
- })
84
-
85
- t.test('in OPTIONS', t => {
86
- t.plan(3)
87
-
88
- sget({
89
- method: 'OPTIONS',
90
- url: getUrl(fastify),
91
- body: '{"hello":"world"}',
92
- headers: {
93
- 'Content-Type': 'application/jsoff'
94
- }
95
- }, (err, response, body) => {
96
- t.error(err)
97
- t.equal(response.statusCode, 200)
98
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
99
- })
100
- })
101
- })
102
- })
103
-
104
- test('contentTypeParser should handle multiple custom parsers', t => {
105
- t.plan(7)
106
- const fastify = Fastify()
107
-
108
- fastify.post('/', (req, reply) => {
109
- reply.send(req.body)
110
- })
111
-
112
- fastify.post('/hello', (req, reply) => {
113
- reply.send(req.body)
114
- })
115
-
116
- function customParser (req, payload, done) {
117
- jsonParser(payload, function (err, body) {
118
- done(err, body)
119
- })
120
- }
121
-
122
- fastify.addContentTypeParser('application/jsoff', customParser)
123
- fastify.addContentTypeParser('application/ffosj', customParser)
124
-
125
- fastify.listen({ port: 0 }, err => {
126
- t.error(err)
127
- t.teardown(() => { fastify.close() })
128
-
129
- sget({
130
- method: 'POST',
131
- url: getUrl(fastify),
132
- body: '{"hello":"world"}',
133
- headers: {
134
- 'Content-Type': 'application/jsoff'
135
- }
136
- }, (err, response, body) => {
137
- t.error(err)
138
- t.equal(response.statusCode, 200)
139
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
140
- })
141
-
142
- sget({
143
- method: 'POST',
144
- url: getUrl(fastify) + '/hello',
145
- body: '{"hello":"world"}',
146
- headers: {
147
- 'Content-Type': 'application/ffosj'
148
- }
149
- }, (err, response, body) => {
150
- t.error(err)
151
- t.equal(response.statusCode, 200)
152
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
153
- })
154
- })
155
- })
156
-
157
- test('contentTypeParser should handle an array of custom contentTypes', t => {
158
- t.plan(7)
159
- const fastify = Fastify()
160
-
161
- fastify.post('/', (req, reply) => {
162
- reply.send(req.body)
163
- })
164
-
165
- fastify.post('/hello', (req, reply) => {
166
- reply.send(req.body)
167
- })
168
-
169
- function customParser (req, payload, done) {
170
- jsonParser(payload, function (err, body) {
171
- done(err, body)
172
- })
173
- }
174
-
175
- fastify.addContentTypeParser(['application/jsoff', 'application/ffosj'], customParser)
176
-
177
- fastify.listen({ port: 0 }, err => {
178
- t.error(err)
179
- t.teardown(() => { fastify.close() })
180
-
181
- sget({
182
- method: 'POST',
183
- url: getUrl(fastify),
184
- body: '{"hello":"world"}',
185
- headers: {
186
- 'Content-Type': 'application/jsoff'
187
- }
188
- }, (err, response, body) => {
189
- t.error(err)
190
- t.equal(response.statusCode, 200)
191
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
192
- })
193
-
194
- sget({
195
- method: 'POST',
196
- url: getUrl(fastify) + '/hello',
197
- body: '{"hello":"world"}',
198
- headers: {
199
- 'Content-Type': 'application/ffosj'
200
- }
201
- }, (err, response, body) => {
202
- t.error(err)
203
- t.equal(response.statusCode, 200)
204
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
205
- })
206
- })
207
- })
208
-
209
- test('contentTypeParser should handle errors', t => {
210
- t.plan(3)
211
- const fastify = Fastify()
212
-
213
- fastify.post('/', (req, reply) => {
214
- reply.send(req.body)
215
- })
216
-
217
- fastify.addContentTypeParser('application/jsoff', function (req, payload, done) {
218
- done(new Error('kaboom!'), {})
219
- })
220
-
221
- fastify.listen({ port: 0 }, err => {
222
- t.error(err)
223
-
224
- sget({
225
- method: 'POST',
226
- url: getUrl(fastify),
227
- body: '{"hello":"world"}',
228
- headers: {
229
- 'Content-Type': 'application/jsoff'
230
- }
231
- }, (err, response, body) => {
232
- t.error(err)
233
- t.equal(response.statusCode, 500)
234
- fastify.close()
235
- })
236
- })
237
- })
238
-
239
- test('contentTypeParser should support encapsulation', t => {
240
- t.plan(6)
241
- const fastify = Fastify()
242
-
243
- fastify.register((instance, opts, done) => {
244
- instance.addContentTypeParser('application/jsoff', () => {})
245
- t.ok(instance.hasContentTypeParser('application/jsoff'))
246
-
247
- instance.register((instance, opts, done) => {
248
- instance.addContentTypeParser('application/ffosj', () => {})
249
- t.ok(instance.hasContentTypeParser('application/jsoff'))
250
- t.ok(instance.hasContentTypeParser('application/ffosj'))
251
- done()
252
- })
253
-
254
- done()
255
- })
256
-
257
- fastify.ready(err => {
258
- t.error(err)
259
- t.notOk(fastify.hasContentTypeParser('application/jsoff'))
260
- t.notOk(fastify.hasContentTypeParser('application/ffosj'))
261
- })
262
- })
263
-
264
- test('contentTypeParser should support encapsulation, second try', t => {
265
- t.plan(4)
266
- const fastify = Fastify()
267
-
268
- fastify.register((instance, opts, done) => {
269
- instance.post('/', (req, reply) => {
270
- reply.send(req.body)
271
- })
272
-
273
- instance.addContentTypeParser('application/jsoff', function (req, payload, done) {
274
- jsonParser(payload, function (err, body) {
275
- done(err, body)
276
- })
277
- })
278
-
279
- done()
280
- })
281
-
282
- fastify.listen({ port: 0 }, err => {
283
- t.error(err)
284
-
285
- sget({
286
- method: 'POST',
287
- url: getUrl(fastify),
288
- body: '{"hello":"world"}',
289
- headers: {
290
- 'Content-Type': 'application/jsoff'
291
- }
292
- }, (err, response, body) => {
293
- t.error(err)
294
- t.equal(response.statusCode, 200)
295
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
296
- fastify.close()
297
- })
298
- })
299
- })
300
-
301
- test('contentTypeParser shouldn\'t support request with undefined "Content-Type"', t => {
302
- t.plan(3)
303
- const fastify = Fastify()
304
-
305
- fastify.post('/', (req, reply) => {
306
- reply.send(req.body)
307
- })
308
-
309
- fastify.addContentTypeParser('application/jsoff', function (req, payload, done) {
310
- jsonParser(payload, function (err, body) {
311
- done(err, body)
312
- })
313
- })
314
-
315
- fastify.listen({ port: 0 }, err => {
316
- t.error(err)
317
-
318
- sget({
319
- method: 'POST',
320
- url: getUrl(fastify),
321
- body: 'unknown content type!',
322
- headers: {
323
- // 'Content-Type': undefined
324
- }
325
- }, (err, response, body) => {
326
- t.error(err)
327
- t.equal(response.statusCode, 415)
328
- fastify.close()
329
- })
330
- })
331
- })
332
-
333
- test('the content type should be a string or RegExp', t => {
334
- t.plan(2)
335
- const fastify = Fastify()
336
-
337
- try {
338
- fastify.addContentTypeParser(null, () => {})
339
- t.fail()
340
- } catch (err) {
341
- t.equal(err.code, 'FST_ERR_CTP_INVALID_TYPE')
342
- t.equal(err.message, 'The content type should be a string or a RegExp')
343
- }
344
- })
345
-
346
- test('the content type cannot be an empty string', t => {
347
- t.plan(2)
348
- const fastify = Fastify()
349
-
350
- try {
351
- fastify.addContentTypeParser('', () => {})
352
- t.fail()
353
- } catch (err) {
354
- t.equal(err.code, 'FST_ERR_CTP_EMPTY_TYPE')
355
- t.equal(err.message, 'The content type cannot be an empty string')
356
- }
357
- })
358
-
359
- test('the content type handler should be a function', t => {
360
- t.plan(2)
361
- const fastify = Fastify()
362
-
363
- try {
364
- fastify.addContentTypeParser('aaa', null)
365
- t.fail()
366
- } catch (err) {
367
- t.equal(err.code, 'FST_ERR_CTP_INVALID_HANDLER')
368
- t.equal(err.message, 'The content type handler should be a function')
369
- }
370
- })
371
-
372
- test('catch all content type parser', t => {
373
- t.plan(7)
374
- const fastify = Fastify()
375
-
376
- fastify.post('/', (req, reply) => {
377
- reply.send(req.body)
378
- })
379
-
380
- fastify.addContentTypeParser('*', function (req, payload, done) {
381
- let data = ''
382
- payload.on('data', chunk => { data += chunk })
383
- payload.on('end', () => {
384
- done(null, data)
385
- })
386
- })
387
-
388
- fastify.listen({ port: 0 }, err => {
389
- t.error(err)
390
-
391
- sget({
392
- method: 'POST',
393
- url: getUrl(fastify),
394
- body: 'hello',
395
- headers: {
396
- 'Content-Type': 'application/jsoff'
397
- }
398
- }, (err, response, body) => {
399
- t.error(err)
400
- t.equal(response.statusCode, 200)
401
- t.same(body.toString(), 'hello')
402
-
403
- sget({
404
- method: 'POST',
405
- url: getUrl(fastify),
406
- body: 'hello',
407
- headers: {
408
- 'Content-Type': 'very-weird-content-type'
409
- }
410
- }, (err, response, body) => {
411
- t.error(err)
412
- t.equal(response.statusCode, 200)
413
- t.same(body.toString(), 'hello')
414
- fastify.close()
415
- })
416
- })
417
- })
418
- })
419
-
420
- test('catch all content type parser should not interfere with other conte type parsers', t => {
421
- t.plan(7)
422
- const fastify = Fastify()
423
-
424
- fastify.post('/', (req, reply) => {
425
- reply.send(req.body)
426
- })
427
-
428
- fastify.addContentTypeParser('*', function (req, payload, done) {
429
- let data = ''
430
- payload.on('data', chunk => { data += chunk })
431
- payload.on('end', () => {
432
- done(null, data)
433
- })
434
- })
435
-
436
- fastify.addContentTypeParser('application/jsoff', function (req, payload, done) {
437
- jsonParser(payload, function (err, body) {
438
- done(err, body)
439
- })
440
- })
441
-
442
- fastify.listen({ port: 0 }, err => {
443
- t.error(err)
444
-
445
- sget({
446
- method: 'POST',
447
- url: getUrl(fastify),
448
- body: '{"hello":"world"}',
449
- headers: {
450
- 'Content-Type': 'application/jsoff'
451
- }
452
- }, (err, response, body) => {
453
- t.error(err)
454
- t.equal(response.statusCode, 200)
455
- t.same(body.toString(), JSON.stringify({ hello: 'world' }))
456
-
457
- sget({
458
- method: 'POST',
459
- url: getUrl(fastify),
460
- body: 'hello',
461
- headers: {
462
- 'Content-Type': 'very-weird-content-type'
463
- }
464
- }, (err, response, body) => {
465
- t.error(err)
466
- t.equal(response.statusCode, 200)
467
- t.same(body.toString(), 'hello')
468
- fastify.close()
469
- })
470
- })
471
- })
472
- })
473
-
474
- // Issue 492 https://github.com/fastify/fastify/issues/492
475
- test('\'*\' catch undefined Content-Type requests', t => {
476
- t.plan(4)
477
-
478
- const fastify = Fastify()
479
-
480
- t.teardown(fastify.close.bind(fastify))
481
-
482
- fastify.addContentTypeParser('*', function (req, payload, done) {
483
- let data = ''
484
- payload.on('data', chunk => { data += chunk })
485
- payload.on('end', () => {
486
- done(null, data)
487
- })
488
- })
489
-
490
- fastify.post('/', (req, res) => {
491
- // Needed to avoid json stringify
492
- res.type('text/plain').send(req.body)
493
- })
494
-
495
- fastify.listen({ port: 0 }, function (err) {
496
- t.error(err)
497
-
498
- const fileStream = fs.createReadStream(__filename)
499
-
500
- sget({
501
- method: 'POST',
502
- url: getUrl(fastify) + '/',
503
- body: fileStream
504
- }, (err, response, body) => {
505
- t.error(err)
506
- t.equal(response.statusCode, 200)
507
- t.equal(body + '', fs.readFileSync(__filename).toString())
508
- })
509
- })
510
- })
511
-
512
- test('cannot add custom parser after binding', t => {
513
- t.plan(2)
514
-
515
- const fastify = Fastify()
516
-
517
- t.teardown(fastify.close.bind(fastify))
518
-
519
- fastify.post('/', (req, res) => {
520
- res.type('text/plain').send(req.body)
521
- })
522
-
523
- fastify.listen({ port: 0 }, function (err) {
524
- t.error(err)
525
-
526
- try {
527
- fastify.addContentTypeParser('*', () => {})
528
- t.fail()
529
- } catch (e) {
530
- t.pass()
531
- }
532
- })
533
- })
534
-
535
- test('Can override the default json parser', t => {
536
- t.plan(5)
537
- const fastify = Fastify()
538
-
539
- fastify.post('/', (req, reply) => {
540
- reply.send(req.body)
541
- })
542
-
543
- fastify.addContentTypeParser('application/json', function (req, payload, done) {
544
- t.ok('called')
545
- jsonParser(payload, function (err, body) {
546
- done(err, body)
547
- })
548
- })
549
-
550
- fastify.listen({ port: 0 }, err => {
551
- t.error(err)
552
-
553
- sget({
554
- method: 'POST',
555
- url: getUrl(fastify),
556
- body: '{"hello":"world"}',
557
- headers: {
558
- 'Content-Type': 'application/json'
559
- }
560
- }, (err, response, body) => {
561
- t.error(err)
562
- t.equal(response.statusCode, 200)
563
- t.equal(body.toString(), '{"hello":"world"}')
564
- fastify.close()
565
- })
566
- })
567
- })
568
-
569
- test('Can override the default plain text parser', t => {
570
- t.plan(5)
571
- const fastify = Fastify()
572
-
573
- fastify.post('/', (req, reply) => {
574
- reply.send(req.body)
575
- })
576
-
577
- fastify.addContentTypeParser('text/plain', function (req, payload, done) {
578
- t.ok('called')
579
- plainTextParser(payload, function (err, body) {
580
- done(err, body)
581
- })
582
- })
583
-
584
- fastify.listen({ port: 0 }, err => {
585
- t.error(err)
586
-
587
- sget({
588
- method: 'POST',
589
- url: getUrl(fastify),
590
- body: 'hello world',
591
- headers: {
592
- 'Content-Type': 'text/plain'
593
- }
594
- }, (err, response, body) => {
595
- t.error(err)
596
- t.equal(response.statusCode, 200)
597
- t.equal(body.toString(), 'hello world')
598
- fastify.close()
599
- })
600
- })
601
- })
602
-
603
- test('Can override the default json parser in a plugin', t => {
604
- t.plan(5)
605
- const fastify = Fastify()
606
-
607
- fastify.register((instance, opts, done) => {
608
- instance.addContentTypeParser('application/json', function (req, payload, done) {
609
- t.ok('called')
610
- jsonParser(payload, function (err, body) {
611
- done(err, body)
612
- })
613
- })
614
-
615
- instance.post('/', (req, reply) => {
616
- reply.send(req.body)
617
- })
618
-
619
- done()
620
- })
621
-
622
- fastify.listen({ port: 0 }, err => {
623
- t.error(err)
624
-
625
- sget({
626
- method: 'POST',
627
- url: getUrl(fastify),
628
- body: '{"hello":"world"}',
629
- headers: {
630
- 'Content-Type': 'application/json'
631
- }
632
- }, (err, response, body) => {
633
- t.error(err)
634
- t.equal(response.statusCode, 200)
635
- t.equal(body.toString(), '{"hello":"world"}')
636
- fastify.close()
637
- })
638
- })
639
- })
640
-
641
- test('Can\'t override the json parser multiple times', t => {
642
- t.plan(2)
643
- const fastify = Fastify()
644
-
645
- fastify.addContentTypeParser('application/json', function (req, payload, done) {
646
- jsonParser(payload, function (err, body) {
647
- done(err, body)
648
- })
649
- })
650
-
651
- try {
652
- fastify.addContentTypeParser('application/json', function (req, payload, done) {
653
- t.ok('called')
654
- jsonParser(payload, function (err, body) {
655
- done(err, body)
656
- })
657
- })
658
- } catch (err) {
659
- t.equal(err.code, 'FST_ERR_CTP_ALREADY_PRESENT')
660
- t.equal(err.message, 'Content type parser \'application/json\' already present.')
661
- }
662
- })
663
-
664
- test('Can\'t override the plain text parser multiple times', t => {
665
- t.plan(2)
666
- const fastify = Fastify()
667
-
668
- fastify.addContentTypeParser('text/plain', function (req, payload, done) {
669
- plainTextParser(payload, function (err, body) {
670
- done(err, body)
671
- })
672
- })
673
-
674
- try {
675
- fastify.addContentTypeParser('text/plain', function (req, payload, done) {
676
- t.ok('called')
677
- plainTextParser(payload, function (err, body) {
678
- done(err, body)
679
- })
680
- })
681
- } catch (err) {
682
- t.equal(err.code, 'FST_ERR_CTP_ALREADY_PRESENT')
683
- t.equal(err.message, 'Content type parser \'text/plain\' already present.')
684
- }
685
- })
686
-
687
- test('Should get the body as string', t => {
688
- t.plan(6)
689
- const fastify = Fastify()
690
-
691
- fastify.post('/', (req, reply) => {
692
- reply.send(req.body)
693
- })
694
-
695
- fastify.addContentTypeParser('application/json', { parseAs: 'string' }, function (req, body, done) {
696
- t.ok('called')
697
- t.ok(typeof body === 'string')
698
- try {
699
- const json = JSON.parse(body)
700
- done(null, json)
701
- } catch (err) {
702
- err.statusCode = 400
703
- done(err, undefined)
704
- }
705
- })
706
-
707
- fastify.listen({ port: 0 }, err => {
708
- t.error(err)
709
-
710
- sget({
711
- method: 'POST',
712
- url: getUrl(fastify),
713
- body: '{"hello":"world"}',
714
- headers: {
715
- 'Content-Type': 'application/json'
716
- }
717
- }, (err, response, body) => {
718
- t.error(err)
719
- t.equal(response.statusCode, 200)
720
- t.equal(body.toString(), '{"hello":"world"}')
721
- fastify.close()
722
- })
723
- })
724
- })
725
-
726
- test('Should return defined body with no custom parser defined and content type = \'text/plain\'', t => {
727
- t.plan(4)
728
- const fastify = Fastify()
729
-
730
- fastify.post('/', (req, reply) => {
731
- reply.send(req.body)
732
- })
733
-
734
- fastify.listen({ port: 0 }, err => {
735
- t.error(err)
736
-
737
- sget({
738
- method: 'POST',
739
- url: getUrl(fastify),
740
- body: 'hello world',
741
- headers: {
742
- 'Content-Type': 'text/plain'
743
- }
744
- }, (err, response, body) => {
745
- t.error(err)
746
- t.equal(response.statusCode, 200)
747
- t.equal(body.toString(), 'hello world')
748
- fastify.close()
749
- })
750
- })
751
- })
752
-
753
- test('Should have typeof body object with no custom parser defined, no body defined and content type = \'text/plain\'', t => {
754
- t.plan(4)
755
- const fastify = Fastify()
756
-
757
- fastify.post('/', (req, reply) => {
758
- reply.send(req.body)
759
- })
760
-
761
- fastify.listen({ port: 0 }, err => {
762
- t.error(err)
763
-
764
- sget({
765
- method: 'POST',
766
- url: getUrl(fastify),
767
- headers: {
768
- 'Content-Type': 'text/plain'
769
- }
770
- }, (err, response, body) => {
771
- t.error(err)
772
- t.equal(response.statusCode, 200)
773
- t.equal(typeof body, 'object')
774
- fastify.close()
775
- })
776
- })
777
- })
778
-
779
38
  test('Should have typeof body object with no custom parser defined, null body and content type = \'text/plain\'', t => {
780
39
  t.plan(4)
781
40
  const fastify = Fastify()