@nestjs/platform-fastify 12.1.2 → 12.2.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.
@@ -61,23 +61,31 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
61
61
  protected _pathPrefix?: string;
62
62
  private readonly openConnections;
63
63
  private isClosing;
64
+ private isShuttingDown;
65
+ private return503OnClosing;
64
66
  private _isParserRegistered;
67
+ private readonly registeredContentTypes;
65
68
  private onRequestHook?;
66
69
  private onResponseHook?;
70
+ private securityHook?;
67
71
  private isMiddieRegistered;
68
72
  private multipartMode;
69
73
  private multipartOptions;
70
74
  private isMultipartRequested;
71
75
  private pendingMiddlewares;
76
+ private readonly middieContexts;
72
77
  private versioningOptions?;
78
+ private readonly versionExtractorErrors;
73
79
  private readonly versionConstraint;
74
80
  get isParserRegistered(): boolean;
75
81
  constructor(instanceOrOptions?: TInstance | FastifyHttp2Options<any> | FastifyHttp2SecureOptions<any> | FastifyHttpsOptions<any> | FastifyHttpOptions<any> | FastifyAdapterBaseOptions<TServer>);
82
+ private runLifecycleHook;
76
83
  setOnRequestHook(hook: (request: TRequest, reply: TReply, done: (err?: Error) => void) => void | Promise<void>): void;
77
84
  setOnResponseHook(hook: (request: TRequest, reply: TReply, done: (err?: Error) => void) => void | Promise<void>): void;
78
85
  init(): Promise<void>;
79
86
  listen(port: string | number, callback?: () => void): void;
80
87
  listen(port: string | number, hostname: string, callback?: () => void): void;
88
+ private isValidPort;
81
89
  get(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
82
90
  post(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
83
91
  head(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
@@ -94,10 +102,11 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
94
102
  move(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
95
103
  lock(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
96
104
  unlock(...args: any[]): FastifyInstance<TServer, TRawRequest, TRawResponse, FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>;
105
+ all(...args: any[]): any;
97
106
  applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute<TRequest, TReply>;
98
107
  reply(response: TRawResponse | TReply, body: any, statusCode?: number): FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
99
108
  status(response: TRawResponse | TReply, statusCode: number): any;
100
- end(response: TReply, message?: string): void;
109
+ end(response: TRawResponse | TReply, message?: string): void;
101
110
  render(response: TReply & {
102
111
  view: Function;
103
112
  }, view: string, options: any): FastifyReply<RouteGenericInterface, RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
@@ -120,14 +129,15 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
120
129
  useMultipart(): void;
121
130
  inject(): LightMyRequestChain;
122
131
  inject(opts: InjectOptions | string): Promise<LightMyRequestResponse>;
132
+ beforeClose(): void;
123
133
  close(): Promise<void>;
124
134
  initHttpServer(options?: NestApplicationOptions): void;
125
135
  useStaticAssets(options: FastifyStaticOptions): any;
126
136
  setViewEngine(options: FastifyViewOptions | string): any;
127
- isHeadersSent(response: TReply): boolean;
128
- getHeader(response: any, name: string): any;
129
- setHeader(response: TReply, name: string, value: string): FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
130
- appendHeader(response: any, name: string, value: string): any;
137
+ isHeadersSent(response: TRawResponse | TReply): boolean;
138
+ getHeader(response: TRawResponse | TReply, name: string): string | number | string[] | undefined;
139
+ setHeader(response: TRawResponse | TReply, name: string, value: string): void | http.ServerResponse<http.IncomingMessage> | FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
140
+ appendHeader(response: TRawResponse | TReply, name: string, value: string): void | http.ServerResponse<http.IncomingMessage> | FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>;
131
141
  getRequestHostname(request: TRequest): string;
132
142
  getRequestMethod(request: TRequest): string;
133
143
  getRequestUrl(request: TRequest): string;
@@ -135,21 +145,27 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
135
145
  enableCors(options?: FastifyCorsOptions): void;
136
146
  /**
137
147
  * Runs the request hook of the built-in HTTP security features in an
138
- * `onRequest` hook: before middie (Nest middleware), content-type parsing,
139
- * guards and handlers, and also for unmatched routes. Headers set by the
140
- * hook go to the Node.js response (`reply.raw`): Fastify merges them into
141
- * every response it sends, errors and `404`s included, while
148
+ * `onRequest` hook added by the constructor: before middie (Nest middleware
149
+ * and `app.use()` middleware, whenever they are registered), content-type
150
+ * parsing, guards and handlers, and also for unmatched routes. Headers set
151
+ * by the hook go to the Node.js response (`reply.raw`): Fastify merges them
152
+ * into every response it sends, errors and `404`s included, while
142
153
  * `reply.header()` / `@Header()` values take precedence, and responses
143
- * written to `reply.raw` directly (e.g. `@Sse()`) carry them too. A
144
- * rejection goes to `done(error)`, i.e. to the Nest exception layer
154
+ * written to `reply.raw` directly (e.g. `@Sse()`, or middleware) carry them
155
+ * too. A rejection goes to `done(error)`, i.e. to the Nest exception layer
145
156
  * installed with `setErrorHandler()`.
146
157
  */
147
158
  registerSecurityHook(hook: SecurityRequestHook<TRequest>): void;
148
159
  registerParserMiddleware(prefix?: string, rawBody?: boolean): void;
149
160
  useBodyParser(type: string | string[] | RegExp, rawBody: boolean, options?: NestFastifyBodyParserOptions, parser?: FastifyBodyParser<Buffer, TServer>): void;
150
161
  createMiddlewareFactory(requestMethod: RequestMethod): Promise<(path: string, callback: Function) => any>;
162
+ private runMiddleware;
151
163
  getType(): string;
152
164
  isRouteOrderSensitive(): boolean;
165
+ getRouteMatchingOptions(): {
166
+ caseSensitive: boolean;
167
+ ignoreTrailingSlash: boolean;
168
+ };
153
169
  use(...args: any[]): any;
154
170
  mapException(error: unknown): unknown;
155
171
  private isHttpFastifyError;
@@ -163,9 +179,22 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
163
179
  private isNativeResponse;
164
180
  private registerJsonContentParser;
165
181
  private registerUrlencodedContentParser;
182
+ private hasCustomBodyParser;
183
+ private normalizeContentType;
184
+ private getDefaultBodyParser;
166
185
  private registerMiddie;
167
186
  private getRequestOriginalUrl;
168
187
  private injectRouteOptions;
188
+ /**
189
+ * "find-my-way" matches an empty path segment for a route parameter
190
+ * ("/users//profile" -> { id: "" }), while "path-to-regexp", which
191
+ * middleware paths (and the ExpressAdapter's routes) are matched with,
192
+ * needs at least one character per parameter. Requests with an empty route
193
+ * parameter are passed to the not-found handler instead, as with the
194
+ * ExpressAdapter, so that middleware and routes always match the same
195
+ * requests. Only the wildcard ("*") may be empty.
196
+ */
197
+ private requireNonEmptyParams;
169
198
  /**
170
199
  * Fastify still accepts the router options ("ignoreTrailingSlash",
171
200
  * "caseSensitive", ...) at the top level, but "initialConfig.routerOptions"
@@ -185,6 +214,24 @@ export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDef
185
214
  * and leaves any other request target untouched.
186
215
  */
187
216
  private getPathFromRequestTarget;
217
+ /**
218
+ * Whether the request target is in origin-form ("/users") or in the
219
+ * absolute-form of an "http(s)" URL ("http://host/users"), the only forms
220
+ * middleware paths can match.
221
+ *
222
+ * Node.js accepts other targets too (e.g. "GET *users HTTP/1.1").
223
+ * "find-my-way" routes those as if their first character were the leading
224
+ * "/" ("*users" is served by the "/users" route), while no middleware path
225
+ * matches them, so the route would run without its middleware. They are
226
+ * answered by the not-found handler instead, as with the ExpressAdapter,
227
+ * whose router never matches a path that does not start with "/".
228
+ *
229
+ * That includes the asterisk-form "OPTIONS *" (RFC 9112, section 3.2.4),
230
+ * which asks about the server as a whole rather than about a resource:
231
+ * Nest has no handler for it, and "find-my-way" would serve it with the
232
+ * "OPTIONS /" route.
233
+ */
234
+ private isRoutableRequestTarget;
188
235
  private trackOpenConnections;
189
236
  private closeOpenConnections;
190
237
  }