@tsed/platform-http 8.11.1 → 8.12.0-rc.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.
Files changed (228) hide show
  1. package/lib/esm/common/builder/PlatformBuilder.js +0 -1
  2. package/lib/esm/common/builder/__fixtures__/PlatformCustom.js +0 -1
  3. package/lib/esm/common/config/interfaces/PlatformJsonMapperSettings.js +0 -1
  4. package/lib/esm/common/config/interfaces/PlatformMulterSettings.js +0 -1
  5. package/lib/esm/common/config/interfaces/PlatformRouterSettings.js +0 -1
  6. package/lib/esm/common/config/interfaces/PlatformStaticsSettings.js +0 -1
  7. package/lib/esm/common/config/services/PlatformConfiguration.js +0 -1
  8. package/lib/esm/common/constants/routerOptions.js +0 -1
  9. package/lib/esm/common/decorators/PlatformProvider.js +0 -1
  10. package/lib/esm/common/decorators/multer/multerFileSize.js +0 -1
  11. package/lib/esm/common/decorators/multer/multerOptions.js +0 -1
  12. package/lib/esm/common/decorators/multer/multipartFile.js +0 -1
  13. package/lib/esm/common/decorators/params/error.js +0 -1
  14. package/lib/esm/common/decorators/params/next.js +0 -1
  15. package/lib/esm/common/decorators/params/request.js +0 -1
  16. package/lib/esm/common/decorators/params/response.js +0 -1
  17. package/lib/esm/common/domain/AnyToPromiseWithCtx.js +0 -1
  18. package/lib/esm/common/domain/EndpointMetadata.js +0 -1
  19. package/lib/esm/common/domain/PlatformContext.js +0 -1
  20. package/lib/esm/common/domain/PlatformRouteDetails.js +0 -1
  21. package/lib/esm/common/exports.js +0 -1
  22. package/lib/esm/common/fn/adapter.js +0 -1
  23. package/lib/esm/common/fn/application.js +0 -1
  24. package/lib/esm/common/index.js +0 -1
  25. package/lib/esm/common/interfaces/AfterInit.js +0 -1
  26. package/lib/esm/common/interfaces/AfterListen.js +0 -1
  27. package/lib/esm/common/interfaces/AfterRoutesInit.js +0 -1
  28. package/lib/esm/common/interfaces/BeforeInit.js +0 -1
  29. package/lib/esm/common/interfaces/BeforeListen.js +0 -1
  30. package/lib/esm/common/interfaces/BeforeRoutesInit.js +0 -1
  31. package/lib/esm/common/interfaces/HandlerType.js +0 -1
  32. package/lib/esm/common/interfaces/IncomingEvent.js +0 -1
  33. package/lib/esm/common/interfaces/OnReady.js +0 -1
  34. package/lib/esm/common/interfaces/OnRequest.js +0 -1
  35. package/lib/esm/common/interfaces/OnResponse.js +0 -1
  36. package/lib/esm/common/interfaces/OnRoutesInit.js +0 -1
  37. package/lib/esm/common/interfaces/PlatformRouteOptions.js +0 -1
  38. package/lib/esm/common/interfaces/ResponseErrorObject.js +0 -1
  39. package/lib/esm/common/interfaces/Route.js +0 -1
  40. package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js +0 -1
  41. package/lib/esm/common/middlewares/PlatformMulterMiddleware.js +0 -1
  42. package/lib/esm/common/services/Platform.js +0 -1
  43. package/lib/esm/common/services/PlatformAdapter.js +0 -1
  44. package/lib/esm/common/services/PlatformApplication.js +0 -1
  45. package/lib/esm/common/services/PlatformHandler.js +0 -1
  46. package/lib/esm/common/services/PlatformRequest.js +0 -1
  47. package/lib/esm/common/services/PlatformResponse.js +0 -1
  48. package/lib/esm/common/utils/closeServer.js +0 -1
  49. package/lib/esm/common/utils/createContext.js +0 -1
  50. package/lib/esm/common/utils/createHttpServer.js +0 -1
  51. package/lib/esm/common/utils/createHttpsServer.js +0 -1
  52. package/lib/esm/common/utils/createInjector.js +0 -1
  53. package/lib/esm/common/utils/createServer.js +0 -1
  54. package/lib/esm/common/utils/ensureContext.js +0 -1
  55. package/lib/esm/common/utils/getConfiguration.js +0 -1
  56. package/lib/esm/common/utils/getStaticsOptions.js +0 -1
  57. package/lib/esm/common/utils/listenServer.js +0 -1
  58. package/lib/esm/common/utils/mapReturnedResponse.js +0 -1
  59. package/lib/esm/common/utils/printRoutes.js +0 -1
  60. package/lib/esm/common/utils/resolveControllers.js +0 -1
  61. package/lib/esm/common/utils/setResponseHeaders.js +0 -1
  62. package/lib/esm/index.js +0 -1
  63. package/lib/esm/testing/FakeAdapter.js +0 -1
  64. package/lib/esm/testing/FakeResponse.js +0 -1
  65. package/lib/esm/testing/PlatformTest.js +0 -1
  66. package/lib/esm/testing/index.js +0 -1
  67. package/package.json +20 -17
  68. package/.barrelsby.json +0 -5
  69. package/lib/esm/common/builder/PlatformBuilder.js.map +0 -1
  70. package/lib/esm/common/builder/__fixtures__/PlatformCustom.js.map +0 -1
  71. package/lib/esm/common/config/interfaces/PlatformJsonMapperSettings.js.map +0 -1
  72. package/lib/esm/common/config/interfaces/PlatformMulterSettings.js.map +0 -1
  73. package/lib/esm/common/config/interfaces/PlatformRouterSettings.js.map +0 -1
  74. package/lib/esm/common/config/interfaces/PlatformStaticsSettings.js.map +0 -1
  75. package/lib/esm/common/config/services/PlatformConfiguration.js.map +0 -1
  76. package/lib/esm/common/constants/routerOptions.js.map +0 -1
  77. package/lib/esm/common/decorators/PlatformProvider.js.map +0 -1
  78. package/lib/esm/common/decorators/multer/multerFileSize.js.map +0 -1
  79. package/lib/esm/common/decorators/multer/multerOptions.js.map +0 -1
  80. package/lib/esm/common/decorators/multer/multipartFile.js.map +0 -1
  81. package/lib/esm/common/decorators/params/error.js.map +0 -1
  82. package/lib/esm/common/decorators/params/next.js.map +0 -1
  83. package/lib/esm/common/decorators/params/request.js.map +0 -1
  84. package/lib/esm/common/decorators/params/response.js.map +0 -1
  85. package/lib/esm/common/domain/AnyToPromiseWithCtx.js.map +0 -1
  86. package/lib/esm/common/domain/EndpointMetadata.js.map +0 -1
  87. package/lib/esm/common/domain/PlatformContext.js.map +0 -1
  88. package/lib/esm/common/domain/PlatformRouteDetails.js.map +0 -1
  89. package/lib/esm/common/exports.js.map +0 -1
  90. package/lib/esm/common/fn/adapter.js.map +0 -1
  91. package/lib/esm/common/fn/application.js.map +0 -1
  92. package/lib/esm/common/index.js.map +0 -1
  93. package/lib/esm/common/interfaces/AfterInit.js.map +0 -1
  94. package/lib/esm/common/interfaces/AfterListen.js.map +0 -1
  95. package/lib/esm/common/interfaces/AfterRoutesInit.js.map +0 -1
  96. package/lib/esm/common/interfaces/BeforeInit.js.map +0 -1
  97. package/lib/esm/common/interfaces/BeforeListen.js.map +0 -1
  98. package/lib/esm/common/interfaces/BeforeRoutesInit.js.map +0 -1
  99. package/lib/esm/common/interfaces/HandlerType.js.map +0 -1
  100. package/lib/esm/common/interfaces/IncomingEvent.js.map +0 -1
  101. package/lib/esm/common/interfaces/OnReady.js.map +0 -1
  102. package/lib/esm/common/interfaces/OnRequest.js.map +0 -1
  103. package/lib/esm/common/interfaces/OnResponse.js.map +0 -1
  104. package/lib/esm/common/interfaces/OnRoutesInit.js.map +0 -1
  105. package/lib/esm/common/interfaces/PlatformRouteOptions.js.map +0 -1
  106. package/lib/esm/common/interfaces/ResponseErrorObject.js.map +0 -1
  107. package/lib/esm/common/interfaces/Route.js.map +0 -1
  108. package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js.map +0 -1
  109. package/lib/esm/common/middlewares/PlatformMulterMiddleware.js.map +0 -1
  110. package/lib/esm/common/services/Platform.js.map +0 -1
  111. package/lib/esm/common/services/PlatformAdapter.js.map +0 -1
  112. package/lib/esm/common/services/PlatformApplication.js.map +0 -1
  113. package/lib/esm/common/services/PlatformHandler.js.map +0 -1
  114. package/lib/esm/common/services/PlatformRequest.js.map +0 -1
  115. package/lib/esm/common/services/PlatformResponse.js.map +0 -1
  116. package/lib/esm/common/utils/closeServer.js.map +0 -1
  117. package/lib/esm/common/utils/createContext.js.map +0 -1
  118. package/lib/esm/common/utils/createHttpServer.js.map +0 -1
  119. package/lib/esm/common/utils/createHttpsServer.js.map +0 -1
  120. package/lib/esm/common/utils/createInjector.js.map +0 -1
  121. package/lib/esm/common/utils/createServer.js.map +0 -1
  122. package/lib/esm/common/utils/ensureContext.js.map +0 -1
  123. package/lib/esm/common/utils/getConfiguration.js.map +0 -1
  124. package/lib/esm/common/utils/getStaticsOptions.js.map +0 -1
  125. package/lib/esm/common/utils/listenServer.js.map +0 -1
  126. package/lib/esm/common/utils/mapReturnedResponse.js.map +0 -1
  127. package/lib/esm/common/utils/printRoutes.js.map +0 -1
  128. package/lib/esm/common/utils/resolveControllers.js.map +0 -1
  129. package/lib/esm/common/utils/setResponseHeaders.js.map +0 -1
  130. package/lib/esm/index.js.map +0 -1
  131. package/lib/esm/testing/FakeAdapter.js.map +0 -1
  132. package/lib/esm/testing/FakeResponse.js.map +0 -1
  133. package/lib/esm/testing/PlatformTest.js.map +0 -1
  134. package/lib/esm/testing/index.js.map +0 -1
  135. package/src/common/builder/PlatformBuilder.spec.ts +0 -331
  136. package/src/common/builder/PlatformBuilder.ts +0 -426
  137. package/src/common/builder/__fixtures__/PlatformCustom.ts +0 -39
  138. package/src/common/config/interfaces/PlatformJsonMapperSettings.ts +0 -11
  139. package/src/common/config/interfaces/PlatformMulterSettings.ts +0 -22
  140. package/src/common/config/interfaces/PlatformRouterSettings.ts +0 -11
  141. package/src/common/config/interfaces/PlatformStaticsSettings.ts +0 -23
  142. package/src/common/config/services/PlatformConfiguration.spec.ts +0 -181
  143. package/src/common/config/services/PlatformConfiguration.ts +0 -158
  144. package/src/common/constants/routerOptions.ts +0 -1
  145. package/src/common/decorators/PlatformProvider.ts +0 -14
  146. package/src/common/decorators/multer/multerFileSize.ts +0 -31
  147. package/src/common/decorators/multer/multerOptions.ts +0 -45
  148. package/src/common/decorators/multer/multipartFile.ts +0 -51
  149. package/src/common/decorators/params/error.spec.ts +0 -15
  150. package/src/common/decorators/params/error.ts +0 -16
  151. package/src/common/decorators/params/next.spec.ts +0 -15
  152. package/src/common/decorators/params/next.ts +0 -31
  153. package/src/common/decorators/params/request.spec.ts +0 -50
  154. package/src/common/decorators/params/request.ts +0 -86
  155. package/src/common/decorators/params/response.spec.ts +0 -37
  156. package/src/common/decorators/params/response.ts +0 -74
  157. package/src/common/domain/AnyToPromiseWithCtx.spec.ts +0 -20
  158. package/src/common/domain/AnyToPromiseWithCtx.ts +0 -30
  159. package/src/common/domain/EndpointMetadata.ts +0 -1
  160. package/src/common/domain/PlatformContext.spec.ts +0 -124
  161. package/src/common/domain/PlatformContext.ts +0 -136
  162. package/src/common/domain/PlatformRouteDetails.ts +0 -7
  163. package/src/common/exports.ts +0 -4
  164. package/src/common/fn/adapter.ts +0 -42
  165. package/src/common/fn/application.ts +0 -11
  166. package/src/common/index.ts +0 -61
  167. package/src/common/interfaces/AfterInit.ts +0 -3
  168. package/src/common/interfaces/AfterListen.ts +0 -3
  169. package/src/common/interfaces/AfterRoutesInit.ts +0 -3
  170. package/src/common/interfaces/BeforeInit.ts +0 -3
  171. package/src/common/interfaces/BeforeListen.ts +0 -3
  172. package/src/common/interfaces/BeforeRoutesInit.ts +0 -3
  173. package/src/common/interfaces/HandlerType.ts +0 -12
  174. package/src/common/interfaces/IncomingEvent.ts +0 -6
  175. package/src/common/interfaces/OnReady.ts +0 -3
  176. package/src/common/interfaces/OnRequest.ts +0 -5
  177. package/src/common/interfaces/OnResponse.ts +0 -5
  178. package/src/common/interfaces/OnRoutesInit.ts +0 -3
  179. package/src/common/interfaces/PlatformRouteOptions.ts +0 -17
  180. package/src/common/interfaces/ResponseErrorObject.ts +0 -8
  181. package/src/common/interfaces/Route.ts +0 -12
  182. package/src/common/middlewares/PlatformAcceptMimesMiddleware.spec.ts +0 -215
  183. package/src/common/middlewares/PlatformAcceptMimesMiddleware.ts +0 -34
  184. package/src/common/middlewares/PlatformMulterMiddleware.ts +0 -6
  185. package/src/common/services/Platform.spec.ts +0 -145
  186. package/src/common/services/Platform.ts +0 -79
  187. package/src/common/services/PlatformAdapter.ts +0 -102
  188. package/src/common/services/PlatformApplication.spec.ts +0 -89
  189. package/src/common/services/PlatformApplication.ts +0 -38
  190. package/src/common/services/PlatformHandler.spec.ts +0 -152
  191. package/src/common/services/PlatformHandler.ts +0 -137
  192. package/src/common/services/PlatformRequest.spec.ts +0 -185
  193. package/src/common/services/PlatformRequest.ts +0 -182
  194. package/src/common/services/PlatformResponse.spec.ts +0 -364
  195. package/src/common/services/PlatformResponse.ts +0 -393
  196. package/src/common/utils/closeServer.spec.ts +0 -11
  197. package/src/common/utils/closeServer.ts +0 -8
  198. package/src/common/utils/createContext.spec.ts +0 -111
  199. package/src/common/utils/createContext.ts +0 -52
  200. package/src/common/utils/createHttpServer.spec.ts +0 -75
  201. package/src/common/utils/createHttpServer.ts +0 -16
  202. package/src/common/utils/createHttpsServer.spec.ts +0 -74
  203. package/src/common/utils/createHttpsServer.ts +0 -17
  204. package/src/common/utils/createInjector.spec.ts +0 -42
  205. package/src/common/utils/createInjector.ts +0 -25
  206. package/src/common/utils/createServer.ts +0 -52
  207. package/src/common/utils/ensureContext.spec.ts +0 -41
  208. package/src/common/utils/ensureContext.ts +0 -17
  209. package/src/common/utils/getConfiguration.spec.ts +0 -163
  210. package/src/common/utils/getConfiguration.ts +0 -34
  211. package/src/common/utils/getStaticsOptions.spec.ts +0 -27
  212. package/src/common/utils/getStaticsOptions.ts +0 -24
  213. package/src/common/utils/listenServer.ts +0 -18
  214. package/src/common/utils/mapReturnedResponse.spec.ts +0 -35
  215. package/src/common/utils/mapReturnedResponse.ts +0 -10
  216. package/src/common/utils/printRoutes.spec.ts +0 -19
  217. package/src/common/utils/printRoutes.ts +0 -40
  218. package/src/common/utils/resolveControllers.spec.ts +0 -40
  219. package/src/common/utils/resolveControllers.ts +0 -54
  220. package/src/common/utils/setResponseHeaders.spec.ts +0 -84
  221. package/src/common/utils/setResponseHeaders.ts +0 -31
  222. package/src/index.ts +0 -2
  223. package/src/testing/FakeAdapter.ts +0 -69
  224. package/src/testing/FakeResponse.ts +0 -115
  225. package/src/testing/PlatformTest.spec.ts +0 -53
  226. package/src/testing/PlatformTest.ts +0 -161
  227. package/src/testing/index.ts +0 -5
  228. package/vitest.config.mts +0 -25
@@ -1,181 +0,0 @@
1
- import {Env} from "@tsed/core";
2
- import {ProviderScope, ProviderType} from "@tsed/di";
3
-
4
- import {PlatformConfiguration} from "./PlatformConfiguration.js";
5
-
6
- describe("PlatformConfiguration", () => {
7
- let settings: any;
8
-
9
- describe("Test ENV", () => {
10
- beforeAll(() => {
11
- settings = new PlatformConfiguration();
12
-
13
- Object.entries({
14
- rootDir: process.cwd(),
15
- env: (process.env.NODE_ENV as Env) || Env.DEV,
16
- port: 8080,
17
- httpPort: 8080,
18
- httpsPort: 8000,
19
- version: "1.0.0",
20
- scopes: {
21
- [ProviderType.CONTROLLER]: ProviderScope.SINGLETON
22
- },
23
- logger: {
24
- debug: false,
25
- level: "info",
26
- logRequest: true,
27
- jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
28
- },
29
- errors: {
30
- headerName: "errors"
31
- },
32
- mount: {},
33
- controllerScope: ProviderScope.SINGLETON
34
- }).forEach(([key, value]) => {
35
- settings[key] = value;
36
- });
37
-
38
- settings.env = Env.TEST;
39
-
40
- settings.set("ownConfig", "test");
41
- settings.set({ownConfig2: "test"} as any);
42
- settings.version = "1.0.0";
43
- settings.httpsOptions = {test: "/rest"} as any;
44
- settings.acceptMimes = ["application/json"];
45
- settings.statics = {"/": "/public"};
46
- settings.routers = {mergeParams: true};
47
- settings.exclude = ["./**/*.spec.ts"];
48
- settings.debug = true;
49
- //settings.jsonMapper = {};
50
-
51
- settings.setHttpPort({address: "address", port: 8081});
52
- settings.setHttpsPort({address: "address", port: 8080});
53
- });
54
-
55
- it("should return rootDir", () => {
56
- expect(settings.rootDir).toEqual(process.cwd());
57
- });
58
-
59
- it("should return custom keys", () => {
60
- expect(settings.get("ownConfig")).toEqual("test");
61
- });
62
-
63
- it("should return env", () => {
64
- expect(settings.env).toEqual(Env.TEST);
65
- });
66
-
67
- it("should have logging jsonIndentaion set to 2", () => {
68
- expect(settings.logger.jsonIndentation).toEqual(2);
69
- });
70
-
71
- it("should return httpsPort", () => {
72
- expect(settings.httpsPort).toEqual("address:8080");
73
- });
74
-
75
- it("should return httpPort", () => {
76
- expect(settings.httpPort).toEqual("address:8081");
77
- });
78
-
79
- it("should return the best host", () => {
80
- const info = settings.getHttpsPort();
81
- expect(info).toEqual({
82
- protocol: "https",
83
- address: "address",
84
- port: 8080,
85
- toString: info.toString
86
- });
87
- expect(settings.getBestHost().toString()).toEqual("https://address:8080");
88
- });
89
-
90
- it("should return httpPort multiple usecase", () => {
91
- const info = settings.getHttpPort();
92
- expect(info).toEqual({
93
- protocol: "http",
94
- address: "address",
95
- port: 8081,
96
- toString: info.toString
97
- });
98
- expect(settings.getBestHost().toString()).toEqual("https://address:8080");
99
-
100
- settings.set("httpsPort", false);
101
- expect(settings.getBestHost().toString()).toEqual("http://address:8081");
102
-
103
- settings.set("httpPort", false);
104
- expect(settings.getBestHost().toString()).toEqual("/");
105
- });
106
-
107
- it("should return httpsOptions", () => {
108
- expect((settings.httpsOptions as any).test).toEqual("/rest");
109
- });
110
-
111
- it("should return acceptMimes", () => {
112
- expect(settings.acceptMimes[0]).toEqual("application/json");
113
- });
114
-
115
- it("should return statics", () => {
116
- expect(settings.statics).toEqual({"/": "/public"});
117
- });
118
-
119
- describe("debug", () => {
120
- it("should expose debug as initialized", () => {
121
- expect(settings.debug).toEqual(true);
122
- });
123
-
124
- it("debug should be equal to the last set value", () => {
125
- settings.debug = false;
126
- expect(settings.debug).toEqual(false);
127
- });
128
- });
129
-
130
- it("should return additionalProperties", () => {
131
- expect(settings.additionalProperties).toEqual(false);
132
- });
133
-
134
- it("should return version", () => {
135
- expect(settings.version).toEqual("1.0.0");
136
- });
137
-
138
- it("should return errors", () => {
139
- expect(settings.errors).toEqual({headerName: "errors"});
140
- });
141
-
142
- it("should return routers", () => {
143
- expect(settings.routers).toEqual({mergeParams: true});
144
- });
145
-
146
- it("should return jsonMapper settings", () => {
147
- expect(settings.jsonMapper).toEqual({
148
- disableUnsecureConstructor: true,
149
- additionalProperties: false,
150
- strictGroups: false
151
- });
152
- });
153
-
154
- it("should return controllerScope", () => {
155
- expect(settings.controllerScope).toEqual("singleton");
156
- });
157
-
158
- it("should return excluded patterns", () => {
159
- expect(settings.exclude).toEqual(["./**/*.spec.ts"]);
160
- });
161
-
162
- describe("forEach()", () => {
163
- it("should loop on items", () => {
164
- const result = [];
165
- settings.forEach((o: any) => result.push(o));
166
- expect(!!result.length).toEqual(true);
167
- });
168
- });
169
-
170
- describe("port", () => {
171
- it("should set port", () => {
172
- const settings = new PlatformConfiguration();
173
-
174
- settings.set({port: 8081});
175
-
176
- expect(settings.httpPort).toEqual(8081);
177
- expect(settings.port).toEqual(8081);
178
- });
179
- });
180
- });
181
- });
@@ -1,158 +0,0 @@
1
- import Https from "node:https";
2
-
3
- import {getHostInfoFromPort, isBoolean} from "@tsed/core";
4
- import {DIConfiguration, Injectable, ProviderScope, TokenProvider} from "@tsed/di";
5
- import {JsonMapperSettings} from "@tsed/json-mapper";
6
-
7
- import {PlatformJsonMapperSettings} from "../interfaces/PlatformJsonMapperSettings.js";
8
-
9
- const rootDir = process.cwd();
10
-
11
- /**
12
- * `PlatformConfiguration` contains all information about your Server configuration.
13
- */
14
- @Injectable({
15
- scope: ProviderScope.SINGLETON,
16
- global: true
17
- })
18
- export class PlatformConfiguration extends DIConfiguration {
19
- constructor() {
20
- super({rootDir});
21
- }
22
-
23
- get port(): string | number | false {
24
- return this.httpPort;
25
- }
26
-
27
- set port(value: string | number | false) {
28
- this.httpPort = value;
29
- }
30
-
31
- get httpsOptions(): Https.ServerOptions {
32
- return this.getRaw("httpsOptions");
33
- }
34
-
35
- set httpsOptions(value: Https.ServerOptions) {
36
- this.setRaw("httpsOptions", value);
37
- }
38
-
39
- get httpPort(): string | number | false {
40
- return this.getRaw("httpPort");
41
- }
42
-
43
- set httpPort(value: string | number | false) {
44
- this.setRaw("httpPort", value);
45
- }
46
-
47
- get httpsPort(): string | number | false {
48
- return this.getRaw("httpsPort");
49
- }
50
-
51
- set httpsPort(value: string | number | false) {
52
- this.setRaw("httpsPort", value);
53
- }
54
-
55
- get mount(): Record<string, TokenProvider[]> {
56
- return this.get("mount");
57
- }
58
-
59
- set mount(value: Record<string, TokenProvider[]>) {
60
- this.setRaw("mount", value);
61
- }
62
-
63
- get statics(): Record<string, (any | string)[]> {
64
- return this.getRaw("statics") || this.getRaw("serveStatic") || {};
65
- }
66
-
67
- set statics(value: Record<string, (any | string)[]>) {
68
- this.setRaw("statics", value);
69
- }
70
-
71
- get acceptMimes(): string[] {
72
- return this.getRaw("acceptMimes");
73
- }
74
-
75
- set acceptMimes(value: string[]) {
76
- this.setRaw("acceptMimes", value || []);
77
- }
78
-
79
- get jsonMapper(): Partial<PlatformJsonMapperSettings> {
80
- return {
81
- ...JsonMapperSettings
82
- };
83
- }
84
-
85
- set jsonMapper(options: Partial<PlatformJsonMapperSettings>) {
86
- JsonMapperSettings.strictGroups = Boolean(options.strictGroups);
87
- JsonMapperSettings.disableUnsecureConstructor = Boolean(options.disableUnsecureConstructor);
88
- JsonMapperSettings.additionalProperties = Boolean(
89
- isBoolean(options.additionalProperties) ? options.additionalProperties : options.additionalProperties === "accept"
90
- );
91
- }
92
-
93
- get additionalProperties() {
94
- return this.get("converter.additionalProperties") === "accept";
95
- }
96
-
97
- /**
98
- *
99
- * @returns {string|number}
100
- */
101
- getHttpPort(): ReturnType<typeof getHostInfoFromPort> {
102
- return getHostInfoFromPort("http", this.getRaw("httpPort"));
103
- }
104
-
105
- /**
106
- *
107
- * @param settings
108
- */
109
- setHttpPort(settings: {address: string; port: number}) {
110
- this.setRaw("httpPort", `${settings.address}:${settings.port}`);
111
- }
112
-
113
- /**
114
- *
115
- * @returns {string|number}
116
- */
117
- getHttpsPort() {
118
- return getHostInfoFromPort("https", this.getRaw("httpsPort"));
119
- }
120
-
121
- /**
122
- *
123
- * @param settings
124
- */
125
- setHttpsPort(settings: {address: string; port: number}) {
126
- this.setRaw("httpsPort", `${settings.address}:${settings.port}`);
127
- }
128
-
129
- getBestHost() {
130
- const {httpsPort, httpPort} = this;
131
-
132
- if (httpsPort) {
133
- return this.getHttpsPort();
134
- }
135
-
136
- if (httpPort) {
137
- return this.getHttpPort();
138
- }
139
-
140
- return {
141
- toString() {
142
- return "/";
143
- }
144
- };
145
- }
146
- }
147
-
148
- declare global {
149
- namespace TsED {
150
- // @ts-ignore
151
- interface Context {}
152
-
153
- /**
154
- * Here to allow extension on DIConfiguration base service
155
- */
156
- interface DIConfiguration extends PlatformConfiguration {}
157
- }
158
- }
@@ -1 +0,0 @@
1
- export const ROUTER_OPTIONS = Symbol.for("ROUTER_OPTIONS");
@@ -1,14 +0,0 @@
1
- import {Type} from "@tsed/core";
2
-
3
- import {adapter} from "../fn/adapter.js";
4
- import {PlatformAdapter} from "../services/PlatformAdapter.js";
5
-
6
- /**
7
- * Register a new platform adapter.
8
- * @decorator
9
- */
10
- export function PlatformProvider() {
11
- return (klass: Type<PlatformAdapter>) => {
12
- adapter(klass);
13
- };
14
- }
@@ -1,31 +0,0 @@
1
- import {MulterFileSize as M} from "@tsed/platform-multer";
2
-
3
- /**
4
- * Define file size limit.
5
- *
6
- * ```typescript
7
- * import {Post} from "@tsed/schema";
8
- * import {MulterOptions, MultipartFile} from "@tsed/platform-multer";
9
- * import {Controller} from "@tsed/di";
10
- * import {Multer} from "@types/multer";
11
- *
12
- * type MulterFile = Express.Multer.File;
13
- *
14
- * @Controller('/')
15
- * class MyCtrl {
16
- * @Post('/file2')
17
- * @MulterFileSize(1024) // (Ko). Applied for all fields
18
- * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
19
- *
20
- * }
21
- * }
22
- * ```
23
- *
24
- * > See the tutorial on the [multer configuration](/docs/upload-files.md).
25
- * @param fileSize
26
- * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
27
- * @decorator
28
- * @deprecated use MulterFileSize from @tsed/platform-multer
29
- * @multer
30
- */
31
- export const MulterFileSize: typeof M = M;
@@ -1,45 +0,0 @@
1
- import {MulterOptions as M} from "@tsed/platform-multer";
2
-
3
- /**
4
- * Define multer option for all MultipartFile
5
- *
6
- * ```typescript
7
- * import {PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/platform-multer";
8
- * import {Controller} from "@tsed/di";
9
- * import {Post} from "@tsed/schema";
10
- *
11
- * @Controller('/')
12
- * class MyCtrl {
13
- * @Post('/file')
14
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
15
- *
16
- * }
17
- *
18
- * @Post('/file')
19
- * @MulterOptions({dest: "/other-dir"})
20
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
21
- *
22
- * }
23
- *
24
- * @Post('/file2')
25
- * @MulterOptions({dest: "/other-dir"})
26
- * private uploadFile(@MultipartFile("file1") file: PlatformMulterFile, @MultipartFile("file2") file2: PlatformMulterFile) {
27
- *
28
- * }
29
- *
30
- * @Post('/files')
31
- * private uploadFile(@MultipartFile("file1") files: PlatformMulterFile[]) {
32
- *
33
- * }
34
- * }
35
- * ```
36
- *
37
- * See the tutorial on the [multer configuration](/docs/upload-files.md).
38
- *
39
- * @param {multer.Options} options
40
- * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
41
- * @decorator
42
- * @multer
43
- * @deprecated use MulterOptions from @tsed/platform-multer
44
- */
45
- export const MulterOptions: typeof M = M;
@@ -1,51 +0,0 @@
1
- import type {MultipartFile as MType} from "@tsed/platform-multer";
2
- import {MultipartFile as M} from "@tsed/platform-multer";
3
-
4
- /**
5
- * Define a parameter as Multipart file.
6
- *
7
- * ```typescript
8
- * import {Post} from "@tsed/schema";
9
- * import {Controller, MulterOptions, MultipartFile} from "@tsed/platform-multer";
10
- * import {Controller} from "@tsed/di";
11
- * import {Multer} from "@types/multer";
12
- *
13
- * type MulterFile = Express.Multer.File;
14
- *
15
- * @Controller('/')
16
- * class MyCtrl {
17
- * @Post('/file')
18
- * private uploadFile(@MultipartFile("file1") file: MulterFile) {
19
- *
20
- * }
21
- *
22
- * @Post('/file')
23
- * @MulterOptions({dest: "/other-dir"})
24
- * private uploadFile(@MultipartFile("file1") file: MulterFile) {
25
- *
26
- * }
27
- *
28
- * @Post('/file2')
29
- * @MulterOptions({dest: "/other-dir"})
30
- * private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
31
- *
32
- * }
33
- *
34
- * @Post('/files')
35
- * private uploadFile(@MultipartFile("file1") files: MulterFile[]) {
36
- *
37
- * }
38
- * }
39
- * ```
40
- *
41
- * > See the tutorial on the [multer configuration](/docs/upload-files.md).
42
- *
43
- * @param name
44
- * @param maxCount
45
- * @returns Function
46
- * @decorator
47
- * @input
48
- * @deprecated use MultipartFile from @tsed/platform-multer
49
- */
50
- export const MultipartFile: typeof M = M;
51
- export type MultipartFile = MType;
@@ -1,15 +0,0 @@
1
- import {ParamTypes} from "@tsed/platform-params";
2
- import {JsonParameterStore} from "@tsed/schema";
3
-
4
- import {Err} from "./error.js";
5
-
6
- describe("@Err", () => {
7
- it("should register a new parameter instance with the correct property", () => {
8
- class Ctrl {
9
- test(@Err() arg: unknown) {}
10
- }
11
-
12
- const param = JsonParameterStore.get(Ctrl, "test", 0);
13
- expect(param.paramType).toEqual(ParamTypes.ERR);
14
- });
15
- });
@@ -1,16 +0,0 @@
1
- import {ParamTypes, UseParam} from "@tsed/platform-params";
2
-
3
- /**
4
- * @returns {Function}
5
- * @decorator
6
- * @operation
7
- * @input
8
- */
9
- export function Err(): Function {
10
- return UseParam({
11
- paramType: ParamTypes.ERR,
12
- dataPath: "$ctx.error",
13
- useValidation: false,
14
- useMapper: false
15
- });
16
- }
@@ -1,15 +0,0 @@
1
- import {ParamTypes} from "@tsed/platform-params";
2
- import {JsonParameterStore} from "@tsed/schema";
3
-
4
- import {Next} from "./next.js";
5
-
6
- describe("@Next", () => {
7
- it("should register a new parameter instance with the correct property", () => {
8
- class Ctrl {
9
- test(@Next() arg: any) {}
10
- }
11
-
12
- const param = JsonParameterStore.get(Ctrl, "test", 0);
13
- expect(param.paramType).toEqual(ParamTypes.NEXT_FN);
14
- });
15
- });
@@ -1,31 +0,0 @@
1
- import {ParamTypes, UseParam} from "@tsed/platform-params";
2
-
3
- /**
4
- * Get the Next function (for express application and middleware).
5
- *
6
- * @decorator
7
- * @operation
8
- * @input
9
- */
10
- export function Next(): ParameterDecorator {
11
- return UseParam({
12
- paramType: ParamTypes.NEXT_FN,
13
- dataPath: "next",
14
- useMapper: false,
15
- useValidation: false
16
- });
17
- }
18
-
19
- declare global {
20
- namespace TsED {
21
- export interface NextFunction extends Function {}
22
- }
23
- }
24
- /**
25
- * Get the Next function (for express application and middleware).
26
- *
27
- * @decorator
28
- * @operation
29
- * @input
30
- */
31
- export type Next = TsED.NextFunction;
@@ -1,50 +0,0 @@
1
- import {IncomingMessage} from "node:http";
2
-
3
- import {ParamTypes} from "@tsed/platform-params";
4
- import {JsonParameterStore} from "@tsed/schema";
5
-
6
- import {PlatformRequest} from "../../services/PlatformRequest.js";
7
- import {Req, Request} from "./request.js";
8
-
9
- describe("@Req", () => {
10
- it("should register a new parameter instance with the correct property (RawRequest)", () => {
11
- class Ctrl {
12
- test(@Request() arg: Req) {}
13
- }
14
-
15
- const param = JsonParameterStore.get(Ctrl, "test", 0);
16
- expect(param.paramType).toEqual(ParamTypes.REQUEST);
17
- expect(param.type).toEqual(Req);
18
- });
19
-
20
- it("should register a new parameter instance with the correct property (RawRequest with expression)", () => {
21
- class Ctrl {
22
- test(@Req("user") arg: Req) {}
23
- }
24
-
25
- const param = JsonParameterStore.get(Ctrl, "test", 0);
26
- expect(param.paramType).toEqual(ParamTypes.REQUEST);
27
- expect(param.expression).toEqual("user");
28
- expect(param.type).toEqual(Req);
29
- });
30
-
31
- it("should register a new parameter instance with the correct property (PlatformRequest)", () => {
32
- class Ctrl {
33
- test(@Req() arg: PlatformRequest) {}
34
- }
35
-
36
- const param = JsonParameterStore.get(Ctrl, "test", 0);
37
- expect(param.paramType).toEqual(ParamTypes.PLATFORM_REQUEST);
38
- expect(param.type).toEqual(PlatformRequest);
39
- });
40
-
41
- it("should register a new parameter instance with the correct property (IncomingMessage)", () => {
42
- class Ctrl {
43
- test(@Req() arg: IncomingMessage) {}
44
- }
45
-
46
- const param = JsonParameterStore.get(Ctrl, "test", 0);
47
- expect(param.paramType).toEqual(ParamTypes.NODE_REQUEST);
48
- expect(param.type).toEqual(IncomingMessage);
49
- });
50
- });