fastify 4.19.2 → 4.21.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/.c8rc.json +8 -0
- package/.taprc +3 -2
- package/README.md +2 -1
- package/SECURITY.md +9 -0
- package/docs/Guides/Prototype-Poisoning.md +2 -2
- package/docs/Reference/Errors.md +39 -17
- package/docs/Reference/Logging.md +1 -1
- package/docs/Reference/Plugins.md +4 -0
- package/docs/Reference/Routes.md +8 -0
- package/docs/Reference/Server.md +230 -178
- package/docs/Reference/TypeScript.md +1 -1
- package/fastify.d.ts +3 -2
- package/fastify.js +36 -17
- package/lib/context.js +6 -0
- package/lib/errors.js +51 -20
- package/lib/fourOhFour.js +5 -9
- package/lib/handleRequest.js +3 -5
- package/lib/hooks.js +91 -25
- package/lib/logger.js +40 -3
- package/lib/reply.js +19 -13
- package/lib/reqIdGenFactory.js +18 -3
- package/lib/route.js +14 -61
- package/lib/schema-controller.js +2 -0
- package/lib/server.js +23 -8
- package/lib/symbols.js +1 -0
- package/package.json +8 -10
- package/test/500s.test.js +22 -0
- package/test/async-await.test.js +1 -1
- package/test/childLoggerFactory.test.js +91 -0
- package/test/encapsulated-child-logger-factory.test.js +69 -0
- package/test/fastify-instance.test.js +43 -10
- package/test/inject.test.js +1 -2
- package/test/internals/errors.test.js +843 -0
- package/test/internals/hookRunner.test.js +22 -8
- package/test/internals/initialConfig.test.js +9 -2
- package/test/internals/reply.test.js +82 -45
- package/test/internals/reqIdGenFactory.test.js +129 -0
- package/test/internals/request-validate.test.js +40 -1
- package/test/internals/request.test.js +14 -4
- package/test/reply-error.test.js +25 -0
- package/test/request-id.test.js +131 -0
- package/test/route.test.js +135 -0
- package/test/serial/logger.0.test.js +6 -1
- package/test/server.test.js +64 -2
- package/test/stream.test.js +4 -4
- package/test/types/errors.test-d.ts +82 -0
- package/test/types/fastify.test-d.ts +4 -0
- package/test/types/instance.test-d.ts +37 -0
- package/test/types/reply.test-d.ts +26 -0
- package/test/types/route.test-d.ts +3 -0
- package/test/types/type-provider.test-d.ts +56 -0
- package/types/errors.d.ts +29 -23
- package/types/instance.d.ts +33 -7
- package/types/logger.d.ts +25 -0
- package/types/reply.d.ts +8 -6
- package/types/route.d.ts +2 -1
- package/types/type-provider.d.ts +2 -1
- package/types/utils.d.ts +9 -0
package/types/type-provider.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RouteGenericInterface } from './route'
|
|
2
2
|
import { FastifySchema } from './schema'
|
|
3
|
+
import { RecordKeysToLowercase } from './utils'
|
|
3
4
|
|
|
4
5
|
// -----------------------------------------------------------------------------------------------
|
|
5
6
|
// TypeProvider
|
|
@@ -51,7 +52,7 @@ export interface FastifyRequestType<Params = unknown, Querystring = unknown, Hea
|
|
|
51
52
|
export interface ResolveFastifyRequestType<TypeProvider extends FastifyTypeProvider, SchemaCompiler extends FastifySchema, RouteGeneric extends RouteGenericInterface> extends FastifyRequestType {
|
|
52
53
|
params: ResolveRequestParams<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
53
54
|
query: ResolveRequestQuerystring<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
54
|
-
headers: ResolveRequestHeaders<TypeProvider, SchemaCompiler, RouteGeneric
|
|
55
|
+
headers: RecordKeysToLowercase<ResolveRequestHeaders<TypeProvider, SchemaCompiler, RouteGeneric>>,
|
|
55
56
|
body: ResolveRequestBody<TypeProvider, SchemaCompiler, RouteGeneric>
|
|
56
57
|
}
|
|
57
58
|
|
package/types/utils.d.ts
CHANGED
|
@@ -69,3 +69,12 @@ export type ReplyKeysToCodes<Key> = [Key] extends [never] ? number :
|
|
|
69
69
|
export type CodeToReplyKey<Code extends number> = `${Code}` extends `${infer FirstDigit extends CodeClasses}${number}`
|
|
70
70
|
? `${FirstDigit}xx`
|
|
71
71
|
: never;
|
|
72
|
+
|
|
73
|
+
export type RecordKeysToLowercase<Input> = Input extends Record<string, unknown>
|
|
74
|
+
? {
|
|
75
|
+
[Key in keyof Input as Key extends string
|
|
76
|
+
? Lowercase<Key>
|
|
77
|
+
: Key
|
|
78
|
+
]: Input[Key];
|
|
79
|
+
}
|
|
80
|
+
: Input;
|