@nestjs/platform-fastify 9.3.1 → 9.3.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/adapters/fastify-adapter.d.ts +3 -0
- package/adapters/fastify-adapter.js +9 -0
- package/index.js +1 -1
- package/interfaces/external/fastify-static-options.interface.d.ts +1 -0
- package/interfaces/external/fastify-view-options.interface.d.ts +1 -0
- package/interfaces/nest-fastify-application.interface.d.ts +3 -0
- package/package.json +2 -2
|
@@ -35,6 +35,9 @@ type VersionedRoute<TRequest, TResponse> = ((req: TRequest, res: TResponse, next
|
|
|
35
35
|
type FastifyRawRequest<TServer extends RawServerBase> = RawRequestDefaultExpression<TServer> & {
|
|
36
36
|
originalUrl?: string;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* @publicApi
|
|
40
|
+
*/
|
|
38
41
|
export declare class FastifyAdapter<TServer extends RawServerBase = RawServerDefault, TRawRequest extends FastifyRawRequest<TServer> = FastifyRawRequest<TServer>, TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>, TRequest extends FastifyRequest<RequestGenericInterface, TServer, TRawRequest> = FastifyRequest<RequestGenericInterface, TServer, TRawRequest>, TReply extends FastifyReply<TServer, TRawRequest, TRawResponse> = FastifyReply<TServer, TRawRequest, TRawResponse>, TInstance extends FastifyInstance<TServer, TRawRequest, TRawResponse> = FastifyInstance<TServer, TRawRequest, TRawResponse>> extends AbstractHttpAdapter<TServer, TRequest, TReply> {
|
|
39
42
|
protected readonly instance: TInstance;
|
|
40
43
|
private _isParserRegistered;
|
|
@@ -10,6 +10,9 @@ const Reply = require("fastify/lib/reply");
|
|
|
10
10
|
const symbols_1 = require("fastify/lib/symbols");
|
|
11
11
|
// `querystring` is used internally in fastify for registering urlencoded body parser.
|
|
12
12
|
const querystring_1 = require("querystring");
|
|
13
|
+
/**
|
|
14
|
+
* @publicApi
|
|
15
|
+
*/
|
|
13
16
|
class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
14
17
|
get isParserRegistered() {
|
|
15
18
|
return !!this._isParserRegistered;
|
|
@@ -175,6 +178,12 @@ class FastifyAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
175
178
|
}
|
|
176
179
|
body = body.getStream();
|
|
177
180
|
}
|
|
181
|
+
if (fastifyReply.getHeader('Content-Type') !== undefined &&
|
|
182
|
+
fastifyReply.getHeader('Content-Type') !== 'application/json' &&
|
|
183
|
+
(body === null || body === void 0 ? void 0 : body.statusCode) >= common_1.HttpStatus.BAD_REQUEST) {
|
|
184
|
+
common_1.Logger.warn("Content-Type doesn't match Reply body, you might need a custom ExceptionFilter for non-JSON responses", FastifyAdapter.name);
|
|
185
|
+
fastifyReply.header('Content-Type', 'application/json');
|
|
186
|
+
}
|
|
178
187
|
return fastifyReply.send(body);
|
|
179
188
|
}
|
|
180
189
|
status(response, statusCode) {
|
package/index.js
CHANGED
|
@@ -4,6 +4,9 @@ import { FastifyBodyParser, FastifyInstance, FastifyPluginAsync, FastifyPluginCa
|
|
|
4
4
|
import { Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request';
|
|
5
5
|
import { FastifyStaticOptions, FastifyViewOptions } from './external';
|
|
6
6
|
import { NestFastifyBodyParserOptions } from './nest-fastify-body-parser-options.interface';
|
|
7
|
+
/**
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
7
10
|
export interface NestFastifyApplication extends INestApplication {
|
|
8
11
|
/**
|
|
9
12
|
* A wrapper function around native `fastify.register()` method.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-fastify",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.2",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"fastify": "4.12.0",
|
|
24
24
|
"light-my-request": "5.8.0",
|
|
25
25
|
"path-to-regexp": "3.2.0",
|
|
26
|
-
"tslib": "2.
|
|
26
|
+
"tslib": "2.5.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@fastify/static": "^6.0.0",
|