@tsed/platform-fastify 8.5.0-beta.2 → 8.8.0-beta.1
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@tsed/platform-multer/fastify";
|
|
1
2
|
import * as Http from "node:http";
|
|
2
3
|
import * as Https from "node:https";
|
|
3
4
|
import fastifyMiddie from "@fastify/middie";
|
|
@@ -5,8 +6,9 @@ import fastifyStatics from "@fastify/static";
|
|
|
5
6
|
import { isFunction, isString } from "@tsed/core";
|
|
6
7
|
import { constant, inject, logger, runInContext } from "@tsed/di";
|
|
7
8
|
import { NotFound } from "@tsed/exceptions";
|
|
9
|
+
import { $alter } from "@tsed/hooks";
|
|
8
10
|
import { PlatformExceptions } from "@tsed/platform-exceptions";
|
|
9
|
-
import { adapter, createContext, createServer,
|
|
11
|
+
import { adapter, createContext, createServer, PlatformAdapter, PlatformBuilder, PlatformRequest, PlatformResponse } from "@tsed/platform-http";
|
|
10
12
|
import { PlatformHandlerType } from "@tsed/platform-router";
|
|
11
13
|
import Fastify from "fastify";
|
|
12
14
|
import { PlatformFastifyRequest } from "../services/PlatformFastifyRequest.js";
|
|
@@ -15,21 +17,6 @@ export class PlatformFastify extends PlatformAdapter {
|
|
|
15
17
|
constructor() {
|
|
16
18
|
super(...arguments);
|
|
17
19
|
this.NAME = "fastify";
|
|
18
|
-
this.providers = [
|
|
19
|
-
{
|
|
20
|
-
token: PlatformHandler
|
|
21
|
-
},
|
|
22
|
-
{ token: PlatformApplication },
|
|
23
|
-
{ token: Platform },
|
|
24
|
-
{
|
|
25
|
-
token: PlatformResponse,
|
|
26
|
-
useClass: PlatformFastifyResponse
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
token: PlatformRequest,
|
|
30
|
-
useClass: PlatformFastifyRequest
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
20
|
this.staticsDecorated = false;
|
|
34
21
|
}
|
|
35
22
|
/**
|
|
@@ -209,14 +196,6 @@ export class PlatformFastify extends PlatformAdapter {
|
|
|
209
196
|
bodyParser(type, opts) {
|
|
210
197
|
return null;
|
|
211
198
|
}
|
|
212
|
-
multipart(options) {
|
|
213
|
-
logger().warn({
|
|
214
|
-
event: "PLATFORM_UNSUPPORTED_FEATURE",
|
|
215
|
-
message: "Multipart method is not implemented yet",
|
|
216
|
-
options
|
|
217
|
-
});
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
199
|
statics(endpoint, options) {
|
|
221
200
|
this.app.getApp().register(fastifyStatics, {
|
|
222
201
|
root: options.root,
|
|
@@ -276,8 +255,17 @@ export class PlatformFastify extends PlatformAdapter {
|
|
|
276
255
|
};
|
|
277
256
|
});
|
|
278
257
|
plugins = await Promise.all(promises);
|
|
279
|
-
return plugins.filter((middleware) => middleware.use).filter((middleware) => middleware.env === env);
|
|
258
|
+
return $alter("$afterPlugins", plugins.filter((middleware) => middleware.use).filter((middleware) => middleware.env === env));
|
|
280
259
|
}
|
|
281
260
|
}
|
|
282
|
-
adapter(PlatformFastify
|
|
261
|
+
adapter(PlatformFastify, [
|
|
262
|
+
{
|
|
263
|
+
token: PlatformResponse,
|
|
264
|
+
useClass: PlatformFastifyResponse
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
token: PlatformRequest,
|
|
268
|
+
useClass: PlatformFastifyRequest
|
|
269
|
+
}
|
|
270
|
+
]);
|
|
283
271
|
//# sourceMappingURL=PlatformFastify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformFastify.js","sourceRoot":"","sources":["../../../src/components/PlatformFastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAW,UAAU,EAAE,QA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;QACE,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE,uBAAuB;KAClC;IACD;QACE,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,sBAAsB;KACjC;CACF,CAAC,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import "@tsed/platform-multer/fastify";
|
|
2
3
|
import * as Http from "node:http";
|
|
3
4
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
4
5
|
import { Type } from "@tsed/core";
|
|
5
|
-
import {
|
|
6
|
+
import { PlatformAdapter, PlatformBuilder, PlatformStaticsOptions } from "@tsed/platform-http";
|
|
6
7
|
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
7
8
|
import Fastify, { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
8
9
|
import type { PlatformFastifyPluginLoadingOptions } from "../interfaces/interfaces.js";
|
|
9
|
-
import { PlatformFastifyRequest } from "../services/PlatformFastifyRequest.js";
|
|
10
|
-
import { PlatformFastifyResponse } from "../services/PlatformFastifyResponse.js";
|
|
11
10
|
declare global {
|
|
12
11
|
namespace TsED {
|
|
13
12
|
interface Application extends FastifyInstance {
|
|
@@ -17,22 +16,6 @@ declare global {
|
|
|
17
16
|
}
|
|
18
17
|
export declare class PlatformFastify extends PlatformAdapter<FastifyInstance> {
|
|
19
18
|
readonly NAME = "fastify";
|
|
20
|
-
readonly providers: ({
|
|
21
|
-
token: typeof PlatformHandler;
|
|
22
|
-
useClass?: undefined;
|
|
23
|
-
} | {
|
|
24
|
-
token: typeof PlatformApplication;
|
|
25
|
-
useClass?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
token: typeof Platform;
|
|
28
|
-
useClass?: undefined;
|
|
29
|
-
} | {
|
|
30
|
-
token: typeof PlatformResponse;
|
|
31
|
-
useClass: typeof PlatformFastifyResponse;
|
|
32
|
-
} | {
|
|
33
|
-
token: typeof PlatformRequest;
|
|
34
|
-
useClass: typeof PlatformFastifyRequest;
|
|
35
|
-
})[];
|
|
36
19
|
private staticsDecorated;
|
|
37
20
|
/**
|
|
38
21
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
@@ -56,7 +39,6 @@ export declare class PlatformFastify extends PlatformAdapter<FastifyInstance> {
|
|
|
56
39
|
afterLoadRoutes(): Promise<void>;
|
|
57
40
|
getServers(): any[];
|
|
58
41
|
bodyParser(type: string, opts: Record<string, any> | undefined): any;
|
|
59
|
-
multipart(options: PlatformMulterSettings): any;
|
|
60
42
|
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
61
43
|
protected compose(layer: PlatformLayer): (req: FastifyRequest, reply: FastifyReply) => Promise<Promise<void>>;
|
|
62
44
|
protected resolvePlugins(): Promise<PlatformFastifyPluginLoadingOptions[]>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-fastify",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.8.0-beta.1",
|
|
5
5
|
"description": "Fastify package for Ts.ED framework",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"build": "yarn barrels && yarn build:ts",
|
|
20
20
|
"barrels": "barrels",
|
|
21
21
|
"start": "node --import @swc-node/register/esm-register test/app/index.ts",
|
|
22
|
-
"test": "vitest run
|
|
23
|
-
"build:ts": "tsc --build tsconfig.json",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"build:ts": "tsc --build tsconfig.esm.json",
|
|
24
24
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
@@ -61,28 +61,29 @@
|
|
|
61
61
|
"@fastify/cookie": "11.0.1",
|
|
62
62
|
"@fastify/formbody": "8.0.1",
|
|
63
63
|
"@fastify/session": "11.0.1",
|
|
64
|
-
"@tsed/barrels": "8.
|
|
65
|
-
"@tsed/core": "8.
|
|
66
|
-
"@tsed/di": "8.
|
|
67
|
-
"@tsed/platform-http": "8.
|
|
68
|
-
"@tsed/platform-test-sdk": "8.
|
|
64
|
+
"@tsed/barrels": "8.8.0-beta.1",
|
|
65
|
+
"@tsed/core": "8.8.0-beta.1",
|
|
66
|
+
"@tsed/di": "8.8.0-beta.1",
|
|
67
|
+
"@tsed/platform-http": "8.8.0-beta.1",
|
|
68
|
+
"@tsed/platform-test-sdk": "8.8.0-beta.1",
|
|
69
69
|
"@types/content-disposition": "^0.5.4",
|
|
70
70
|
"cross-env": "7.0.3",
|
|
71
71
|
"fastify": "5.2.1",
|
|
72
72
|
"fastify-raw-body": "5.0.0",
|
|
73
|
-
"ts-node": "10.9.2"
|
|
73
|
+
"ts-node": "10.9.2",
|
|
74
|
+
"vitest": "3.0.9"
|
|
74
75
|
},
|
|
75
76
|
"peerDependencies": {
|
|
76
77
|
"@fastify/accepts": ">=4.3.0",
|
|
77
78
|
"@fastify/cookie": ">=9.3.1",
|
|
78
79
|
"@fastify/formbody": ">=7.4.0",
|
|
79
|
-
"@tsed/core": ">=8.
|
|
80
|
-
"@tsed/di": ">=8.
|
|
81
|
-
"@tsed/json-mapper": ">=8.
|
|
80
|
+
"@tsed/core": ">=8.8.0-beta.1",
|
|
81
|
+
"@tsed/di": ">=8.8.0-beta.1",
|
|
82
|
+
"@tsed/json-mapper": ">=8.8.0-beta.1",
|
|
82
83
|
"@tsed/logger": ">=7.0.0",
|
|
83
|
-
"@tsed/openspec": ">=8.
|
|
84
|
-
"@tsed/platform-http": ">=8.
|
|
85
|
-
"@tsed/schema": ">=8.
|
|
84
|
+
"@tsed/openspec": ">=8.8.0-beta.1",
|
|
85
|
+
"@tsed/platform-http": ">=8.8.0-beta.1",
|
|
86
|
+
"@tsed/schema": ">=8.8.0-beta.1",
|
|
86
87
|
"fastify": ">=5.1.0",
|
|
87
88
|
"fastify-raw-body": ">=5.0.0"
|
|
88
89
|
},
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "@tsed/platform-multer/fastify";
|
|
2
|
+
|
|
1
3
|
import * as Http from "node:http";
|
|
2
4
|
import {IncomingMessage, ServerResponse} from "node:http";
|
|
3
5
|
import * as Https from "node:https";
|
|
@@ -7,17 +9,14 @@ import fastifyStatics from "@fastify/static";
|
|
|
7
9
|
import {type Env, isFunction, isString, ReturnHostInfoFromPort, Type} from "@tsed/core";
|
|
8
10
|
import {constant, inject, logger, runInContext} from "@tsed/di";
|
|
9
11
|
import {NotFound} from "@tsed/exceptions";
|
|
12
|
+
import {$alter} from "@tsed/hooks";
|
|
10
13
|
import {PlatformExceptions} from "@tsed/platform-exceptions";
|
|
11
14
|
import {
|
|
12
15
|
adapter,
|
|
13
16
|
createContext,
|
|
14
17
|
createServer,
|
|
15
|
-
Platform,
|
|
16
18
|
PlatformAdapter,
|
|
17
|
-
PlatformApplication,
|
|
18
19
|
PlatformBuilder,
|
|
19
|
-
PlatformHandler,
|
|
20
|
-
PlatformMulterSettings,
|
|
21
20
|
PlatformRequest,
|
|
22
21
|
PlatformResponse,
|
|
23
22
|
PlatformStaticsOptions
|
|
@@ -40,22 +39,6 @@ declare global {
|
|
|
40
39
|
|
|
41
40
|
export class PlatformFastify extends PlatformAdapter<FastifyInstance> {
|
|
42
41
|
readonly NAME = "fastify";
|
|
43
|
-
|
|
44
|
-
readonly providers = [
|
|
45
|
-
{
|
|
46
|
-
token: PlatformHandler
|
|
47
|
-
},
|
|
48
|
-
{token: PlatformApplication},
|
|
49
|
-
{token: Platform},
|
|
50
|
-
{
|
|
51
|
-
token: PlatformResponse,
|
|
52
|
-
useClass: PlatformFastifyResponse
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
token: PlatformRequest,
|
|
56
|
-
useClass: PlatformFastifyRequest
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
42
|
private staticsDecorated = false;
|
|
60
43
|
|
|
61
44
|
/**
|
|
@@ -273,15 +256,6 @@ export class PlatformFastify extends PlatformAdapter<FastifyInstance> {
|
|
|
273
256
|
return null;
|
|
274
257
|
}
|
|
275
258
|
|
|
276
|
-
multipart(options: PlatformMulterSettings): any {
|
|
277
|
-
logger().warn({
|
|
278
|
-
event: "PLATFORM_UNSUPPORTED_FEATURE",
|
|
279
|
-
message: "Multipart method is not implemented yet",
|
|
280
|
-
options
|
|
281
|
-
});
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
259
|
statics(endpoint: string, options: PlatformStaticsOptions): any {
|
|
286
260
|
this.app.getApp().register(fastifyStatics, {
|
|
287
261
|
root: options.root,
|
|
@@ -354,8 +328,20 @@ export class PlatformFastify extends PlatformAdapter<FastifyInstance> {
|
|
|
354
328
|
|
|
355
329
|
plugins = await Promise.all(promises);
|
|
356
330
|
|
|
357
|
-
return
|
|
331
|
+
return $alter(
|
|
332
|
+
"$afterPlugins",
|
|
333
|
+
plugins.filter((middleware) => middleware.use).filter((middleware) => middleware.env === env)
|
|
334
|
+
);
|
|
358
335
|
}
|
|
359
336
|
}
|
|
360
337
|
|
|
361
|
-
adapter(PlatformFastify
|
|
338
|
+
adapter(PlatformFastify, [
|
|
339
|
+
{
|
|
340
|
+
token: PlatformResponse,
|
|
341
|
+
useClass: PlatformFastifyResponse
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
token: PlatformRequest,
|
|
345
|
+
useClass: PlatformFastifyRequest
|
|
346
|
+
}
|
|
347
|
+
]);
|
package/vitest.config.mts
CHANGED
|
@@ -10,12 +10,12 @@ export default defineConfig(
|
|
|
10
10
|
coverage: {
|
|
11
11
|
...presets.test.coverage,
|
|
12
12
|
thresholds: {
|
|
13
|
-
statements:
|
|
14
|
-
branches:
|
|
15
|
-
functions:
|
|
16
|
-
lines:
|
|
13
|
+
statements: 93.84,
|
|
14
|
+
branches: 91.42,
|
|
15
|
+
functions: 90,
|
|
16
|
+
lines: 93.84
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
);
|
|
21
|
+
);
|