fastify 4.23.0 → 4.23.2
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/docs/Reference/Request.md +1 -1
- package/fastify.js +1 -1
- package/lib/warnings.js +2 -2
- package/package.json +1 -1
- package/test/types/request.test-d.ts +5 -1
- package/types/request.d.ts +14 -12
|
@@ -31,7 +31,7 @@ Request is a core Fastify object containing the following fields:
|
|
|
31
31
|
original `url` in case of internal re-routing
|
|
32
32
|
- `routerMethod` - Deprecated, use `request.routeOptions.method` instead. The
|
|
33
33
|
method defined for the router that is handling the request
|
|
34
|
-
- `routerPath` - Deprecated, use `request.routeOptions.
|
|
34
|
+
- `routerPath` - Deprecated, use `request.routeOptions.url` instead. The
|
|
35
35
|
path pattern defined for the router that is handling the request
|
|
36
36
|
- `is404` - true if request is being handled by 404 handler, false if it is not
|
|
37
37
|
- `connection` - Deprecated, use `socket` instead. The underlying connection of
|
package/fastify.js
CHANGED
package/lib/warnings.js
CHANGED
|
@@ -31,9 +31,9 @@ warning.create('FastifyDeprecation', 'FSTDEP015', 'You are accessing the depreca
|
|
|
31
31
|
|
|
32
32
|
warning.create('FastifyDeprecation', 'FSTDEP016', 'You are accessing the deprecated "request.routeConfig" property. Use "request.routeOptions.config" instead. Property "req.routeConfig" will be removed in `fastify@5`.')
|
|
33
33
|
|
|
34
|
-
warning.create('FastifyDeprecation', 'FSTDEP017', 'You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.
|
|
34
|
+
warning.create('FastifyDeprecation', 'FSTDEP017', 'You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.')
|
|
35
35
|
|
|
36
|
-
warning.create('FastifyDeprecation', 'FSTDEP018', 'You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.
|
|
36
|
+
warning.create('FastifyDeprecation', 'FSTDEP018', 'You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.method" instead. Property "req.routerMethod" will be removed in `fastify@5`.')
|
|
37
37
|
|
|
38
38
|
warning.create('FastifyWarning', 'FSTWRN001', 'The %s schema for %s: %s is missing. This may indicate the schema is not well specified.', { unlimited: true })
|
|
39
39
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { expectAssignable, expectType } from 'tsd'
|
|
|
3
3
|
import fastify, {
|
|
4
4
|
ContextConfigDefault,
|
|
5
5
|
FastifyContext,
|
|
6
|
+
FastifyContextConfig,
|
|
6
7
|
FastifyLogFn,
|
|
7
8
|
FastifySchema,
|
|
8
9
|
FastifyTypeProviderDefault,
|
|
@@ -18,7 +19,7 @@ import { FastifyInstance } from '../../types/instance'
|
|
|
18
19
|
import { FastifyLoggerInstance } from '../../types/logger'
|
|
19
20
|
import { FastifyReply } from '../../types/reply'
|
|
20
21
|
import { FastifyRequest, RequestRouteOptions } from '../../types/request'
|
|
21
|
-
import { RouteGenericInterface } from '../../types/route'
|
|
22
|
+
import { FastifyRouteConfig, RouteGenericInterface } from '../../types/route'
|
|
22
23
|
import { RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from '../../types/utils'
|
|
23
24
|
|
|
24
25
|
interface RequestBody {
|
|
@@ -77,7 +78,10 @@ const getHandler: RouteHandler = function (request, _reply) {
|
|
|
77
78
|
expectType<FastifyContext<ContextConfigDefault>>(request.context)
|
|
78
79
|
expectType<FastifyContext<ContextConfigDefault>['config']>(request.context.config)
|
|
79
80
|
expectType<FastifyContext<ContextConfigDefault>['config']>(request.routeConfig)
|
|
81
|
+
expectType<FastifyContext<ContextConfigDefault>['config']>(request.routeOptions.config)
|
|
82
|
+
expectType<ContextConfigDefault & FastifyRouteConfig & FastifyContextConfig>(request.routeOptions.config)
|
|
80
83
|
expectType<FastifySchema>(request.routeSchema)
|
|
84
|
+
expectType<FastifySchema>(request.routeOptions.schema)
|
|
81
85
|
|
|
82
86
|
expectType<RequestHeadersDefault & RawRequestDefaultExpression['headers']>(request.headers)
|
|
83
87
|
request.headers = {}
|
package/types/request.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ErrorObject } from '@fastify/ajv-compiler'
|
|
2
|
-
import { FastifyContext } from './context'
|
|
2
|
+
import { FastifyContext, FastifyContextConfig } from './context'
|
|
3
3
|
import { FastifyInstance } from './instance'
|
|
4
4
|
import { FastifyBaseLogger } from './logger'
|
|
5
|
-
import { RouteGenericInterface } from './route'
|
|
5
|
+
import { RouteGenericInterface, FastifyRouteConfig } from './route'
|
|
6
6
|
import { FastifySchema } from './schema'
|
|
7
7
|
import { FastifyRequestType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyRequestType } from './type-provider'
|
|
8
8
|
import { ContextConfigDefault, RawRequestDefaultExpression, RawServerBase, RawServerDefault, RequestBodyDefault, RequestHeadersDefault, RequestParamsDefault, RequestQuerystringDefault } from './utils'
|
|
@@ -20,15 +20,17 @@ export interface ValidationFunction {
|
|
|
20
20
|
errors?: null | ErrorObject[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export interface RequestRouteOptions {
|
|
24
|
-
method: string
|
|
25
|
-
url: string
|
|
26
|
-
bodyLimit:number
|
|
27
|
-
attachValidation:boolean
|
|
28
|
-
logLevel:string
|
|
29
|
-
version: string | undefined
|
|
30
|
-
exposeHeadRoute: boolean
|
|
31
|
-
prefixTrailingSlash: string
|
|
23
|
+
export interface RequestRouteOptions<ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema> {
|
|
24
|
+
method: string;
|
|
25
|
+
url: string;
|
|
26
|
+
bodyLimit:number;
|
|
27
|
+
attachValidation:boolean;
|
|
28
|
+
logLevel:string;
|
|
29
|
+
version: string | undefined;
|
|
30
|
+
exposeHeadRoute: boolean;
|
|
31
|
+
prefixTrailingSlash: string;
|
|
32
|
+
config: FastifyContextConfig & FastifyRouteConfig & ContextConfig;
|
|
33
|
+
schema: SchemaCompiler;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -78,7 +80,7 @@ export interface FastifyRequest<RouteGeneric extends RouteGenericInterface = Rou
|
|
|
78
80
|
readonly method: string;
|
|
79
81
|
readonly routerPath: string;
|
|
80
82
|
readonly routerMethod: string;
|
|
81
|
-
readonly routeOptions: Readonly<RequestRouteOptions
|
|
83
|
+
readonly routeOptions: Readonly<RequestRouteOptions<ContextConfig, SchemaCompiler>>
|
|
82
84
|
readonly is404: boolean;
|
|
83
85
|
readonly socket: RawRequest['socket'];
|
|
84
86
|
|