fastify 5.11.3 → 6.0.0-alpha.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.
- package/README.md +2 -2
- package/SPONSORS.md +1 -0
- package/build/build-validation.js +20 -34
- package/docs/Guides/Getting-Started.md +2 -2
- package/docs/Guides/Serverless.md +34 -2
- package/docs/Reference/Errors.md +5 -3
- package/docs/Reference/Hooks.md +0 -4
- package/docs/Reference/LTS.md +6 -5
- package/docs/Reference/Server.md +8 -88
- package/docs/Reference/TypeScript.md +3 -49
- package/docs/Reference/Warnings.md +4 -11
- package/fastify.d.ts +10 -24
- package/fastify.js +17 -34
- package/lib/config-validator.js +368 -475
- package/lib/errors.js +9 -3
- package/lib/log-controller.js +2 -4
- package/lib/logger-factory.js +1 -1
- package/lib/route.js +4 -9
- package/lib/server.js +2 -3
- package/lib/warnings.js +2 -46
- package/package.json +2 -3
- package/test/404s.test.js +0 -49
- package/test/allow-unsafe-regex.test.js +12 -4
- package/test/case-insensitive.test.js +12 -4
- package/test/custom-querystring-parser.test.js +0 -16
- package/test/hooks.test.js +6 -1
- package/test/http-methods/custom-http-methods.test.js +12 -17
- package/test/http-methods/trace.test.js +1 -1
- package/test/https/custom-https-server.test.js +1 -1
- package/test/internals/errors.test.js +15 -5
- package/test/internals/initial-config.test.js +56 -38
- package/test/internals/logger.test.js +17 -4
- package/test/internals/reply.test.js +1 -1
- package/test/internals/request.test.js +8 -24
- package/test/logger/logging.test.js +2 -121
- package/test/logger/request.test.js +1 -36
- package/test/plugin.4.test.js +5 -4
- package/test/route-prefix.test.js +46 -18
- package/test/route.1.test.js +2 -2
- package/test/router-options.test.js +25 -523
- package/test/set-error-handler.test.js +7 -9
- package/test/types/errors.tst.ts +2 -1
- package/test/types/fastify.tst.ts +44 -48
- package/test/types/instance.tst.ts +4 -5
- package/test/types/logger.tst.ts +3 -7
- package/test/use-semicolon-delimiter.test.js +0 -60
- package/types/context.d.ts +0 -20
- package/types/errors.d.ts +2 -1
- package/types/instance.d.ts +0 -4
- package/types/logger.d.ts +1 -16
- package/types/plugin.d.ts +0 -9
- package/types/request.d.ts +0 -4
- package/lib/promise.js +0 -23
- package/test/internals/promise.test.js +0 -63
|
@@ -459,7 +459,9 @@ test('prefix "/prefix/" does not match "/prefix" with a / route', (t, testDone)
|
|
|
459
459
|
test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: true', (t, testDone) => {
|
|
460
460
|
t.plan(4)
|
|
461
461
|
const fastify = Fastify({
|
|
462
|
-
|
|
462
|
+
routerOptions: {
|
|
463
|
+
ignoreTrailingSlash: true
|
|
464
|
+
}
|
|
463
465
|
})
|
|
464
466
|
|
|
465
467
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -493,7 +495,9 @@ test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: tr
|
|
|
493
495
|
test('matches both /prefix and /prefix/ with a / route - ignoreDuplicateSlashes: true', (t, testDone) => {
|
|
494
496
|
t.plan(4)
|
|
495
497
|
const fastify = Fastify({
|
|
496
|
-
|
|
498
|
+
routerOptions: {
|
|
499
|
+
ignoreDuplicateSlashes: true
|
|
500
|
+
}
|
|
497
501
|
})
|
|
498
502
|
|
|
499
503
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -527,7 +531,9 @@ test('matches both /prefix and /prefix/ with a / route - ignoreDuplicateSlashes:
|
|
|
527
531
|
test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "both", ignoreTrailingSlash: false', (t, testDone) => {
|
|
528
532
|
t.plan(4)
|
|
529
533
|
const fastify = Fastify({
|
|
530
|
-
|
|
534
|
+
routerOptions: {
|
|
535
|
+
ignoreTrailingSlash: false
|
|
536
|
+
}
|
|
531
537
|
})
|
|
532
538
|
|
|
533
539
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -566,7 +572,9 @@ test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "
|
|
|
566
572
|
test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "both", ignoreDuplicateSlashes: false', (t, testDone) => {
|
|
567
573
|
t.plan(4)
|
|
568
574
|
const fastify = Fastify({
|
|
569
|
-
|
|
575
|
+
routerOptions: {
|
|
576
|
+
ignoreDuplicateSlashes: false
|
|
577
|
+
}
|
|
570
578
|
})
|
|
571
579
|
|
|
572
580
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -605,8 +613,10 @@ test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "
|
|
|
605
613
|
test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: true, ignoreDuplicateSlashes: true', (t, testDone) => {
|
|
606
614
|
t.plan(4)
|
|
607
615
|
const fastify = Fastify({
|
|
608
|
-
|
|
609
|
-
|
|
616
|
+
routerOptions: {
|
|
617
|
+
ignoreTrailingSlash: true,
|
|
618
|
+
ignoreDuplicateSlashes: true
|
|
619
|
+
}
|
|
610
620
|
})
|
|
611
621
|
|
|
612
622
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -640,8 +650,10 @@ test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: tr
|
|
|
640
650
|
test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: true, ignoreDuplicateSlashes: false', (t, testDone) => {
|
|
641
651
|
t.plan(4)
|
|
642
652
|
const fastify = Fastify({
|
|
643
|
-
|
|
644
|
-
|
|
653
|
+
routerOptions: {
|
|
654
|
+
ignoreTrailingSlash: true,
|
|
655
|
+
ignoreDuplicateSlashes: false
|
|
656
|
+
}
|
|
645
657
|
})
|
|
646
658
|
|
|
647
659
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -675,7 +687,9 @@ test('matches both /prefix and /prefix/ with a / route - ignoreTrailingSlash: tr
|
|
|
675
687
|
test('returns 404 status code with /prefix/ and / route - prefixTrailingSlash: "both" (default), ignoreTrailingSlash: true', (t, testDone) => {
|
|
676
688
|
t.plan(2)
|
|
677
689
|
const fastify = Fastify({
|
|
678
|
-
|
|
690
|
+
routerOptions: {
|
|
691
|
+
ignoreTrailingSlash: true
|
|
692
|
+
}
|
|
679
693
|
})
|
|
680
694
|
|
|
681
695
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -707,7 +721,9 @@ test('returns 404 status code with /prefix/ and / route - prefixTrailingSlash: "
|
|
|
707
721
|
test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "both", ignoreDuplicateSlashes: true', (t, testDone) => {
|
|
708
722
|
t.plan(2)
|
|
709
723
|
const fastify = Fastify({
|
|
710
|
-
|
|
724
|
+
routerOptions: {
|
|
725
|
+
ignoreDuplicateSlashes: true
|
|
726
|
+
}
|
|
711
727
|
})
|
|
712
728
|
|
|
713
729
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -735,8 +751,10 @@ test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "
|
|
|
735
751
|
test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "both", ignoreTrailingSlash: true, ignoreDuplicateSlashes: true', (t, testDone) => {
|
|
736
752
|
t.plan(2)
|
|
737
753
|
const fastify = Fastify({
|
|
738
|
-
|
|
739
|
-
|
|
754
|
+
routerOptions: {
|
|
755
|
+
ignoreTrailingSlash: true,
|
|
756
|
+
ignoreDuplicateSlashes: true
|
|
757
|
+
}
|
|
740
758
|
})
|
|
741
759
|
|
|
742
760
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -764,8 +782,10 @@ test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "
|
|
|
764
782
|
test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "both", ignoreDuplicateSlashes: true', (t, testDone) => {
|
|
765
783
|
t.plan(2)
|
|
766
784
|
const fastify = Fastify({
|
|
767
|
-
|
|
768
|
-
|
|
785
|
+
routerOptions: {
|
|
786
|
+
ignoreTrailingSlash: true,
|
|
787
|
+
ignoreDuplicateSlashes: true
|
|
788
|
+
}
|
|
769
789
|
})
|
|
770
790
|
|
|
771
791
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -793,7 +813,9 @@ test('matches both /prefix and /prefix/ with a / route - prefixTrailingSlash: "
|
|
|
793
813
|
test('matches only /prefix with a / route - prefixTrailingSlash: "no-slash", ignoreTrailingSlash: false', (t, testDone) => {
|
|
794
814
|
t.plan(4)
|
|
795
815
|
const fastify = Fastify({
|
|
796
|
-
|
|
816
|
+
routerOptions: {
|
|
817
|
+
ignoreTrailingSlash: false
|
|
818
|
+
}
|
|
797
819
|
})
|
|
798
820
|
|
|
799
821
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -832,7 +854,9 @@ test('matches only /prefix with a / route - prefixTrailingSlash: "no-slash", ig
|
|
|
832
854
|
test('matches only /prefix with a / route - prefixTrailingSlash: "no-slash", ignoreDuplicateSlashes: false', (t, testDone) => {
|
|
833
855
|
t.plan(4)
|
|
834
856
|
const fastify = Fastify({
|
|
835
|
-
|
|
857
|
+
routerOptions: {
|
|
858
|
+
ignoreDuplicateSlashes: false
|
|
859
|
+
}
|
|
836
860
|
})
|
|
837
861
|
|
|
838
862
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -871,7 +895,9 @@ test('matches only /prefix with a / route - prefixTrailingSlash: "no-slash", ig
|
|
|
871
895
|
test('matches only /prefix/ with a / route - prefixTrailingSlash: "slash", ignoreTrailingSlash: false', (t, testDone) => {
|
|
872
896
|
t.plan(4)
|
|
873
897
|
const fastify = Fastify({
|
|
874
|
-
|
|
898
|
+
routerOptions: {
|
|
899
|
+
ignoreTrailingSlash: false
|
|
900
|
+
}
|
|
875
901
|
})
|
|
876
902
|
|
|
877
903
|
fastify.register(function (fastify, opts, done) {
|
|
@@ -910,7 +936,9 @@ test('matches only /prefix/ with a / route - prefixTrailingSlash: "slash", igno
|
|
|
910
936
|
test('calls onRoute only once when prefixing', async t => {
|
|
911
937
|
t.plan(1)
|
|
912
938
|
const fastify = Fastify({
|
|
913
|
-
|
|
939
|
+
routerOptions: {
|
|
940
|
+
ignoreTrailingSlash: false
|
|
941
|
+
},
|
|
914
942
|
exposeHeadRoutes: false
|
|
915
943
|
})
|
|
916
944
|
|
package/test/route.1.test.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { test } = require('node:test')
|
|
4
4
|
const Fastify = require('..')
|
|
5
5
|
const {
|
|
6
|
-
|
|
6
|
+
FST_ERR_INSTANCE_ALREADY_STARTED,
|
|
7
7
|
FST_ERR_ROUTE_METHOD_INVALID
|
|
8
8
|
} = require('../lib/errors')
|
|
9
9
|
const { getServerUrl } = require('./helper')
|
|
@@ -230,7 +230,7 @@ test('route', async t => {
|
|
|
230
230
|
handler: function (req, reply) {
|
|
231
231
|
reply.send({ hello: 'world' })
|
|
232
232
|
}
|
|
233
|
-
}), new
|
|
233
|
+
}), new FST_ERR_INSTANCE_ALREADY_STARTED('Cannot add route!'))
|
|
234
234
|
})
|
|
235
235
|
})
|
|
236
236
|
|