exisjs 0.5.4 → 0.5.6

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 (218) hide show
  1. package/dist/app/index.d.ts +4 -0
  2. package/dist/app/index.d.ts.map +1 -0
  3. package/dist/app/index.js +12 -0
  4. package/dist/app/index.js.map +1 -0
  5. package/dist/auth/index.d.ts +6 -0
  6. package/dist/auth/index.d.ts.map +1 -0
  7. package/dist/{exports/auth.js → auth/index.js} +5 -5
  8. package/dist/auth/index.js.map +1 -0
  9. package/dist/cache/index.d.ts +2 -0
  10. package/dist/cache/index.d.ts.map +1 -1
  11. package/dist/cache/index.js +16 -0
  12. package/dist/cache/index.js.map +1 -1
  13. package/dist/cli/commands/dev.d.ts.map +1 -1
  14. package/dist/cli/commands/dev.js +96 -6
  15. package/dist/cli/commands/dev.js.map +1 -1
  16. package/dist/cli/commands/exports.js +2 -2
  17. package/dist/cli/commands/exports.js.map +1 -1
  18. package/dist/cli/commands/init.js +1 -1
  19. package/dist/cli/commands/init.js.map +1 -1
  20. package/dist/cli/manifest.d.ts.map +1 -1
  21. package/dist/cli/manifest.js +13 -0
  22. package/dist/cli/manifest.js.map +1 -1
  23. package/dist/cli/routes.d.ts.map +1 -1
  24. package/dist/cli/routes.js.map +1 -1
  25. package/dist/{exports/config.d.ts → config/index.d.ts} +2 -2
  26. package/dist/config/index.d.ts.map +1 -0
  27. package/dist/{exports/config.js → config/index.js} +2 -2
  28. package/dist/config/index.js.map +1 -0
  29. package/dist/dataloader/index.d.ts +3 -0
  30. package/dist/dataloader/index.d.ts.map +1 -0
  31. package/dist/{exports/response.js → dataloader/index.js} +3 -2
  32. package/dist/dataloader/index.js.map +1 -0
  33. package/dist/decorators/constants.d.ts +45 -0
  34. package/dist/decorators/constants.d.ts.map +1 -0
  35. package/dist/decorators/constants.js +19 -0
  36. package/dist/decorators/constants.js.map +1 -0
  37. package/dist/decorators/core.d.ts +29 -0
  38. package/dist/decorators/core.d.ts.map +1 -0
  39. package/dist/decorators/core.js +140 -0
  40. package/dist/decorators/core.js.map +1 -0
  41. package/dist/decorators/index.d.ts +6 -184
  42. package/dist/decorators/index.d.ts.map +1 -1
  43. package/dist/decorators/index.js +9 -680
  44. package/dist/decorators/index.js.map +1 -1
  45. package/dist/decorators/middleware.d.ts +37 -0
  46. package/dist/decorators/middleware.d.ts.map +1 -0
  47. package/dist/decorators/middleware.js +290 -0
  48. package/dist/decorators/middleware.js.map +1 -0
  49. package/dist/decorators/params.d.ts +18 -0
  50. package/dist/decorators/params.d.ts.map +1 -0
  51. package/dist/decorators/params.js +106 -0
  52. package/dist/decorators/params.js.map +1 -0
  53. package/dist/decorators/response.d.ts +32 -0
  54. package/dist/decorators/response.d.ts.map +1 -0
  55. package/dist/decorators/response.js +93 -0
  56. package/dist/decorators/response.js.map +1 -0
  57. package/dist/decorators/routing.d.ts +39 -0
  58. package/dist/decorators/routing.d.ts.map +1 -0
  59. package/dist/decorators/routing.js +75 -0
  60. package/dist/decorators/routing.js.map +1 -0
  61. package/dist/di/container.d.ts.map +1 -1
  62. package/dist/di/container.js +2 -1
  63. package/dist/di/container.js.map +1 -1
  64. package/dist/di/index.d.ts +4 -0
  65. package/dist/di/index.d.ts.map +1 -0
  66. package/dist/{exports/di.js → di/index.js} +3 -3
  67. package/dist/di/index.js.map +1 -0
  68. package/dist/{exports/error.d.ts → error/index.d.ts} +1 -1
  69. package/dist/error/index.d.ts.map +1 -0
  70. package/dist/{exports/error.js → error/index.js} +1 -1
  71. package/dist/error/index.js.map +1 -0
  72. package/dist/index.d.ts +2 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +1 -39
  75. package/dist/index.js.map +1 -1
  76. package/dist/integrations/mongoose.d.ts +2 -2
  77. package/dist/integrations/mongoose.d.ts.map +1 -1
  78. package/dist/integrations/mongoose.js +28 -7
  79. package/dist/integrations/mongoose.js.map +1 -1
  80. package/dist/lib/start-server.js +42 -3
  81. package/dist/lib/start-server.js.map +1 -1
  82. package/dist/middleware/cache.d.ts.map +1 -1
  83. package/dist/middleware/cache.js +4 -2
  84. package/dist/middleware/cache.js.map +1 -1
  85. package/dist/middleware/dedupe.d.ts +11 -0
  86. package/dist/middleware/dedupe.d.ts.map +1 -1
  87. package/dist/middleware/dedupe.js +12 -1
  88. package/dist/middleware/dedupe.js.map +1 -1
  89. package/dist/module/index.d.ts +3 -0
  90. package/dist/module/index.d.ts.map +1 -0
  91. package/dist/{exports/module.js → module/index.js} +2 -2
  92. package/dist/module/index.js.map +1 -0
  93. package/dist/observability/metrics.d.ts +6 -0
  94. package/dist/observability/metrics.d.ts.map +1 -0
  95. package/dist/observability/metrics.js +60 -0
  96. package/dist/observability/metrics.js.map +1 -0
  97. package/dist/{exports/plugin.d.ts → plugin/index.d.ts} +1 -1
  98. package/dist/plugin/index.d.ts.map +1 -0
  99. package/dist/{exports/plugin.js → plugin/index.js} +1 -1
  100. package/dist/plugin/index.js.map +1 -0
  101. package/dist/queue/client.d.ts.map +1 -1
  102. package/dist/queue/client.js +20 -1
  103. package/dist/queue/client.js.map +1 -1
  104. package/dist/queue/index.d.ts +6 -0
  105. package/dist/queue/index.d.ts.map +1 -1
  106. package/dist/queue/index.js +10 -0
  107. package/dist/queue/index.js.map +1 -1
  108. package/dist/router/gateway.d.ts.map +1 -1
  109. package/dist/router/gateway.js.map +1 -1
  110. package/dist/{exports/route.d.ts → router/index.d.ts} +3 -3
  111. package/dist/router/index.d.ts.map +1 -0
  112. package/dist/{exports/route.js → router/index.js} +2 -2
  113. package/dist/router/index.js.map +1 -0
  114. package/dist/{exports/sanitize.d.ts → sanitize/index.d.ts} +1 -1
  115. package/dist/sanitize/index.d.ts.map +1 -0
  116. package/dist/{exports/sanitize.js → sanitize/index.js} +1 -1
  117. package/dist/sanitize/index.js.map +1 -0
  118. package/dist/server/app.d.ts +1 -0
  119. package/dist/server/app.d.ts.map +1 -1
  120. package/dist/server/app.js +62 -0
  121. package/dist/server/app.js.map +1 -1
  122. package/dist/server/bootstrapper.d.ts.map +1 -1
  123. package/dist/server/bootstrapper.js +12 -9
  124. package/dist/server/bootstrapper.js.map +1 -1
  125. package/dist/server/define.d.ts +13 -3
  126. package/dist/server/define.d.ts.map +1 -1
  127. package/dist/server/define.js +63 -11
  128. package/dist/server/define.js.map +1 -1
  129. package/dist/server/dev-error-overlay.d.ts.map +1 -1
  130. package/dist/server/dev-error-overlay.js +3 -1
  131. package/dist/server/dev-error-overlay.js.map +1 -1
  132. package/dist/server/request.d.ts +1 -1
  133. package/dist/server/request.d.ts.map +1 -1
  134. package/dist/server/route-scanner.d.ts +1 -0
  135. package/dist/server/route-scanner.d.ts.map +1 -1
  136. package/dist/server/route-scanner.js +61 -48
  137. package/dist/server/route-scanner.js.map +1 -1
  138. package/dist/server/route.d.ts.map +1 -1
  139. package/dist/server/route.js +6 -1
  140. package/dist/server/route.js.map +1 -1
  141. package/dist/{exports/storage.d.ts → storage/index.d.ts} +1 -1
  142. package/dist/storage/index.d.ts.map +1 -0
  143. package/dist/{exports/storage.js → storage/index.js} +1 -1
  144. package/dist/storage/index.js.map +1 -0
  145. package/dist/testing/client.d.ts +6 -3
  146. package/dist/testing/client.d.ts.map +1 -1
  147. package/dist/testing/client.js +12 -1
  148. package/dist/testing/client.js.map +1 -1
  149. package/dist/types.d.ts +23 -0
  150. package/dist/types.d.ts.map +1 -1
  151. package/dist/utils/config.d.ts.map +1 -1
  152. package/dist/utils/config.js +14 -0
  153. package/dist/utils/config.js.map +1 -1
  154. package/dist/utils/errors.d.ts.map +1 -1
  155. package/dist/utils/errors.js +59 -5
  156. package/dist/utils/errors.js.map +1 -1
  157. package/dist/utils/logger.d.ts.map +1 -1
  158. package/dist/utils/logger.js +21 -0
  159. package/dist/utils/logger.js.map +1 -1
  160. package/dist/utils/worker.d.ts +15 -0
  161. package/dist/utils/worker.d.ts.map +1 -0
  162. package/dist/utils/worker.js +50 -0
  163. package/dist/utils/worker.js.map +1 -0
  164. package/dist/{exports/validation.d.ts → validator/index.d.ts} +1 -1
  165. package/dist/validator/index.d.ts.map +1 -0
  166. package/dist/{exports/validation.js → validator/index.js} +1 -1
  167. package/dist/validator/index.js.map +1 -0
  168. package/package.json +41 -43
  169. package/dist/exports/app.d.ts +0 -2
  170. package/dist/exports/app.d.ts.map +0 -1
  171. package/dist/exports/app.js +0 -8
  172. package/dist/exports/app.js.map +0 -1
  173. package/dist/exports/auth.d.ts +0 -6
  174. package/dist/exports/auth.d.ts.map +0 -1
  175. package/dist/exports/auth.js.map +0 -1
  176. package/dist/exports/cache.d.ts +0 -4
  177. package/dist/exports/cache.d.ts.map +0 -1
  178. package/dist/exports/cache.js +0 -20
  179. package/dist/exports/cache.js.map +0 -1
  180. package/dist/exports/config.d.ts.map +0 -1
  181. package/dist/exports/config.js.map +0 -1
  182. package/dist/exports/dataloader.d.ts +0 -3
  183. package/dist/exports/dataloader.d.ts.map +0 -1
  184. package/dist/exports/dataloader.js +0 -19
  185. package/dist/exports/dataloader.js.map +0 -1
  186. package/dist/exports/decorators.d.ts +0 -2
  187. package/dist/exports/decorators.d.ts.map +0 -1
  188. package/dist/exports/decorators.js +0 -18
  189. package/dist/exports/decorators.js.map +0 -1
  190. package/dist/exports/di.d.ts +0 -4
  191. package/dist/exports/di.d.ts.map +0 -1
  192. package/dist/exports/di.js.map +0 -1
  193. package/dist/exports/error.d.ts.map +0 -1
  194. package/dist/exports/error.js.map +0 -1
  195. package/dist/exports/module.d.ts +0 -3
  196. package/dist/exports/module.d.ts.map +0 -1
  197. package/dist/exports/module.js.map +0 -1
  198. package/dist/exports/plugin.d.ts.map +0 -1
  199. package/dist/exports/plugin.js.map +0 -1
  200. package/dist/exports/queue.d.ts +0 -9
  201. package/dist/exports/queue.d.ts.map +0 -1
  202. package/dist/exports/queue.js +0 -16
  203. package/dist/exports/queue.js.map +0 -1
  204. package/dist/exports/response.d.ts +0 -2
  205. package/dist/exports/response.d.ts.map +0 -1
  206. package/dist/exports/response.js.map +0 -1
  207. package/dist/exports/route.d.ts.map +0 -1
  208. package/dist/exports/route.js.map +0 -1
  209. package/dist/exports/sanitize.d.ts.map +0 -1
  210. package/dist/exports/sanitize.js.map +0 -1
  211. package/dist/exports/storage.d.ts.map +0 -1
  212. package/dist/exports/storage.js.map +0 -1
  213. package/dist/exports/swagger.d.ts +0 -3
  214. package/dist/exports/swagger.d.ts.map +0 -1
  215. package/dist/exports/swagger.js +0 -6
  216. package/dist/exports/swagger.js.map +0 -1
  217. package/dist/exports/validation.d.ts.map +0 -1
  218. package/dist/exports/validation.js.map +0 -1
@@ -10,685 +10,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.GATEWAY_CONFIG = exports.SERVER_CONFIG = exports.Hosts = exports.Permissions = exports.Redirect = exports.Res = exports.UploadedFiles = exports.UploadedFile = exports.Ip = exports.Next = exports.Session = exports.Stream = exports.Socket = exports.Req = exports.HostParam = exports.Headers = exports.Body = exports.Param = exports.Sse = exports.Ws = exports.Trace = exports.Connect = exports.All = exports.Head = exports.Options = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.PARAM_METADATA = exports.LIFECYCLE_METADATA = exports.ROUTE_METADATA = exports.MIDDLEWARE_REGISTRY = exports.CONTROLLER_HOST = exports.CONTROLLER_PREFIX = exports.ROUTE_REGISTRY = void 0;
37
- exports.Controller = Controller;
38
- exports.Use = Use;
39
- exports.Idempotent = Idempotent;
40
- exports.Cache = Cache;
41
- exports.HttpCode = HttpCode;
42
- exports.Header = Header;
43
- exports.Returns = Returns;
44
- exports.UseGuards = UseGuards;
45
- exports.UseInterceptors = UseInterceptors;
46
- exports.UseFilters = UseFilters;
47
- exports.Query = Query;
48
- exports.Injectable = Injectable;
49
- exports.Server = Server;
50
- exports.Gateway = Gateway;
51
- // Store metadata on class prototypes using symbols to avoid reflect-metadata
52
- exports.ROUTE_REGISTRY = Symbol.for('exisjs:routes');
53
- exports.CONTROLLER_PREFIX = Symbol.for('exisjs:controller_prefix');
54
- exports.CONTROLLER_HOST = Symbol.for('exisjs:controller_host');
55
- exports.MIDDLEWARE_REGISTRY = Symbol.for('exisjs:middlewares');
56
- exports.ROUTE_METADATA = Symbol.for('exisjs:route_metadata');
57
- exports.LIFECYCLE_METADATA = Symbol.for('exisjs:lifecycle_metadata');
58
- exports.PARAM_METADATA = Symbol.for('exisjs:param_metadata');
59
- const ROUTE_META = Symbol.for('exisjs:route_meta');
60
- const METHOD_MIDDLEWARES = Symbol.for('exisjs:method_middlewares');
61
- const ROUTE_METADATA_PROP = Symbol.for('exisjs:route_metadata_prop');
62
- const LIFECYCLE_METADATA_PROP = Symbol.for('exisjs:lifecycle_metadata_prop');
63
- const PARAM_METADATA_PROP = Symbol.for('exisjs:param_metadata_prop');
64
- /**
65
- * Marks a class as a controller, automatically grouping its routes under the provided prefix.
66
- * Uses standard ES decorators, completely avoiding reflect-metadata bloat.
67
- *
68
- * Example:
69
- *
70
- * @Controller('/api/users')
71
- * export class UserController {
72
- * @Get()
73
- * getUsers() { return []; }
74
- * }
75
- *
76
- * @param {string | ControllerOptions} [prefixOrOptions] Route prefix or options
77
- * @public
78
- */
79
- function Controller(prefixOrOptions) {
80
- return function (target, context) {
81
- const prefix = typeof prefixOrOptions === 'string'
82
- ? prefixOrOptions
83
- : prefixOrOptions?.prefix || '';
84
- const host = typeof prefixOrOptions === 'object' ? prefixOrOptions.host : undefined;
85
- target.prototype[exports.CONTROLLER_PREFIX] = prefix;
86
- if (host)
87
- target.prototype[exports.CONTROLLER_HOST] = host;
88
- if (context && context.metadata) {
89
- context.metadata[exports.CONTROLLER_PREFIX] = prefix;
90
- if (host)
91
- context.metadata[exports.CONTROLLER_HOST] = host;
92
- }
93
- // Aggregate metadata from methods to the prototype registry
94
- const proto = target.prototype;
95
- proto[exports.ROUTE_REGISTRY] = proto[exports.ROUTE_REGISTRY] || [];
96
- // Middlewares
97
- const currentMiddlewares = proto[exports.MIDDLEWARE_REGISTRY];
98
- if (Array.isArray(currentMiddlewares)) {
99
- proto[exports.MIDDLEWARE_REGISTRY] = {
100
- _classMiddlewares: currentMiddlewares,
101
- };
102
- }
103
- else if (!proto[exports.MIDDLEWARE_REGISTRY] ||
104
- typeof proto[exports.MIDDLEWARE_REGISTRY] !== 'object') {
105
- proto[exports.MIDDLEWARE_REGISTRY] = {
106
- _classMiddlewares: [],
107
- };
108
- }
109
- else if (!proto[exports.MIDDLEWARE_REGISTRY]._classMiddlewares) {
110
- proto[exports.MIDDLEWARE_REGISTRY]._classMiddlewares = [];
111
- }
112
- // Response Metadata, Guards/Interceptors, and Parameters
113
- const classLifecycle = proto[LIFECYCLE_METADATA_PROP] || {};
114
- proto[exports.ROUTE_METADATA] = proto[exports.ROUTE_METADATA] || {};
115
- proto[exports.LIFECYCLE_METADATA] = proto[exports.LIFECYCLE_METADATA] || {};
116
- proto[exports.PARAM_METADATA] = proto[exports.PARAM_METADATA] || {};
117
- for (const key of Object.getOwnPropertyNames(proto)) {
118
- const descriptor = Object.getOwnPropertyDescriptor(proto, key);
119
- if (descriptor && typeof descriptor.value === 'function') {
120
- const fn = descriptor.value;
121
- // 1. Collect route definition
122
- const routeMeta = fn[ROUTE_META];
123
- if (routeMeta) {
124
- proto[exports.ROUTE_REGISTRY].push({
125
- method: routeMeta.method,
126
- path: routeMeta.path,
127
- schema: routeMeta.schema,
128
- handlerName: key,
129
- });
130
- }
131
- // 2. Collect method middlewares
132
- const methodMiddlewares = fn[METHOD_MIDDLEWARES];
133
- if (methodMiddlewares) {
134
- proto[exports.MIDDLEWARE_REGISTRY][key] =
135
- proto[exports.MIDDLEWARE_REGISTRY][key] || [];
136
- proto[exports.MIDDLEWARE_REGISTRY][key].push(...methodMiddlewares);
137
- }
138
- // 3. Collect custom HttpCode / Header response metadata
139
- const classRouteMetadata = proto[ROUTE_METADATA_PROP] || {};
140
- const routeMetadata = fn[ROUTE_METADATA_PROP] || {};
141
- if (Object.keys(classRouteMetadata).length > 0 ||
142
- Object.keys(routeMetadata).length > 0) {
143
- proto[exports.ROUTE_METADATA][key] = {
144
- ...classRouteMetadata,
145
- ...routeMetadata,
146
- };
147
- }
148
- // 4. Collect Guards and Interceptors (merging class-level and method-level)
149
- const lifecycleMetadata = fn[LIFECYCLE_METADATA_PROP] || {};
150
- proto[exports.LIFECYCLE_METADATA][key] = {
151
- guards: [
152
- ...(classLifecycle._classGuards || []),
153
- ...(lifecycleMetadata.guards || []),
154
- ],
155
- interceptors: [
156
- ...(classLifecycle._classInterceptors || []),
157
- ...(lifecycleMetadata.interceptors || []),
158
- ],
159
- filters: [
160
- ...(classLifecycle._classFilters || []),
161
- ...(lifecycleMetadata.filters || []),
162
- ],
163
- };
164
- // 5. Collect parameter injection metadata
165
- const paramMetadata = fn[PARAM_METADATA_PROP];
166
- if (paramMetadata) {
167
- proto[exports.PARAM_METADATA][key] = paramMetadata;
168
- }
169
- }
170
- }
171
- };
172
- }
173
- function createMethodDecorator(method) {
174
- return function (path = '', schema) {
175
- return function (target, contextOrPropertyKey, descriptor) {
176
- if (typeof contextOrPropertyKey === 'object' &&
177
- contextOrPropertyKey !== null &&
178
- 'name' in contextOrPropertyKey) {
179
- // TS 5.0 Standard Method Decorator
180
- ;
181
- target[ROUTE_META] = {
182
- method,
183
- path,
184
- schema,
185
- };
186
- }
187
- else {
188
- // Legacy/Experimental Decorator fallback
189
- const proto = typeof target === 'function' ? target.prototype : target;
190
- const name = contextOrPropertyKey || descriptor?.name;
191
- if (!proto[exports.ROUTE_REGISTRY])
192
- proto[exports.ROUTE_REGISTRY] = [];
193
- proto[exports.ROUTE_REGISTRY].push({
194
- method,
195
- path,
196
- schema,
197
- handlerName: name,
198
- });
199
- }
200
- };
201
- };
202
- }
203
- /**
204
- * Marks a method as a GET route handler.
205
- *
206
- * Example:
207
- *
208
- * @Get('/:id')
209
- * getUser(@Param('id') id: string) { return { id }; }
210
- *
211
- * @param {string} [path] The route path
212
- * @param {RouteSchema} [schema] Optional validation schema
213
- * @public
214
- */
215
- exports.Get = createMethodDecorator('GET');
216
- /**
217
- * Marks a method as a POST route handler.
218
- *
219
- * Example:
220
- *
221
- * @Post('/', { body: v.object({ name: v.string() }) })
222
- * createUser(@Body() body: any) { return body; }
223
- *
224
- * @param {string} [path] The route path
225
- * @param {RouteSchema} [schema] Optional validation schema
226
- * @public
227
- */
228
- exports.Post = createMethodDecorator('POST');
229
- exports.Put = createMethodDecorator('PUT');
230
- exports.Patch = createMethodDecorator('PATCH');
231
- exports.Delete = createMethodDecorator('DELETE');
232
- exports.Options = createMethodDecorator('OPTIONS');
233
- exports.Head = createMethodDecorator('HEAD');
234
- exports.All = createMethodDecorator('ALL');
235
- exports.Connect = createMethodDecorator('CONNECT');
236
- exports.Trace = createMethodDecorator('TRACE');
237
- exports.Ws = createMethodDecorator('WS');
238
- exports.Sse = createMethodDecorator('SSE');
239
- /**
240
- * Applies middleware to a Controller class or route method.
241
- *
242
- * Example:
243
- *
244
- * @Use(requireAuth)
245
- * @Get('/dashboard')
246
- * getDashboard() {}
247
- *
248
- * @param {...any} middlewares Middleware functions
249
- * @public
250
- */
251
- function Use(...middlewares) {
252
- return function (target, contextOrPropertyKey, _descriptor) {
253
- if (typeof contextOrPropertyKey === 'object' &&
254
- contextOrPropertyKey !== null) {
255
- const context = contextOrPropertyKey;
256
- if (context.kind === 'class') {
257
- if (context.metadata) {
258
- if (!context.metadata[exports.MIDDLEWARE_REGISTRY] ||
259
- Array.isArray(context.metadata[exports.MIDDLEWARE_REGISTRY])) {
260
- context.metadata[exports.MIDDLEWARE_REGISTRY] = {
261
- _classMiddlewares: context.metadata[exports.MIDDLEWARE_REGISTRY] || [],
262
- };
263
- }
264
- else if (!context.metadata[exports.MIDDLEWARE_REGISTRY]._classMiddlewares) {
265
- context.metadata[exports.MIDDLEWARE_REGISTRY]._classMiddlewares = [];
266
- }
267
- context.metadata[exports.MIDDLEWARE_REGISTRY]._classMiddlewares.push(...middlewares);
268
- }
269
- if (!target.prototype[exports.MIDDLEWARE_REGISTRY] ||
270
- Array.isArray(target.prototype[exports.MIDDLEWARE_REGISTRY])) {
271
- target.prototype[exports.MIDDLEWARE_REGISTRY] = {
272
- _classMiddlewares: target.prototype[exports.MIDDLEWARE_REGISTRY] || [],
273
- };
274
- }
275
- else if (!target.prototype[exports.MIDDLEWARE_REGISTRY]._classMiddlewares) {
276
- target.prototype[exports.MIDDLEWARE_REGISTRY]._classMiddlewares = [];
277
- }
278
- target.prototype[exports.MIDDLEWARE_REGISTRY]._classMiddlewares.push(...middlewares);
279
- }
280
- else if (context.kind === 'method') {
281
- // TS 5.0 Standard Method Decorator
282
- ;
283
- target[METHOD_MIDDLEWARES] =
284
- target[METHOD_MIDDLEWARES] || [];
285
- target[METHOD_MIDDLEWARES].push(...middlewares);
286
- }
287
- }
288
- else {
289
- if (typeof target === 'function' && !contextOrPropertyKey) {
290
- // Legacy class decorator
291
- const proto = target.prototype;
292
- if (!proto[exports.MIDDLEWARE_REGISTRY] ||
293
- Array.isArray(proto[exports.MIDDLEWARE_REGISTRY])) {
294
- proto[exports.MIDDLEWARE_REGISTRY] = {
295
- _classMiddlewares: proto[exports.MIDDLEWARE_REGISTRY] || [],
296
- };
297
- }
298
- else if (!proto[exports.MIDDLEWARE_REGISTRY]._classMiddlewares) {
299
- proto[exports.MIDDLEWARE_REGISTRY]._classMiddlewares = [];
300
- }
301
- proto[exports.MIDDLEWARE_REGISTRY]._classMiddlewares.push(...middlewares);
302
- }
303
- else {
304
- // Legacy method decorator
305
- const proto = target;
306
- const name = contextOrPropertyKey;
307
- if (!proto[exports.MIDDLEWARE_REGISTRY])
308
- proto[exports.MIDDLEWARE_REGISTRY] = {};
309
- if (!proto[exports.MIDDLEWARE_REGISTRY][name])
310
- proto[exports.MIDDLEWARE_REGISTRY][name] = [];
311
- proto[exports.MIDDLEWARE_REGISTRY][name].push(...middlewares);
312
- }
313
- }
314
- };
315
- }
316
- /**
317
- * Idempotency Decorator.
318
- * Caches responses based on the provided Idempotency-Key header.
319
- *
320
- * Example:
321
- * @Post('/checkout')
322
- * @Idempotent()
323
- * checkout() {}
324
- */
325
- function Idempotent(options = {}) {
326
- return function (target, contextOrPropertyKey, descriptor) {
327
- const isStandard = typeof contextOrPropertyKey === 'object' && contextOrPropertyKey !== null;
328
- const fn = isStandard ? target : descriptor.value;
329
- fn[METHOD_MIDDLEWARES] = fn[METHOD_MIDDLEWARES] || [];
330
- // Defer import to avoid circular dependencies
331
- const middlewareProxy = async (req, res, next) => {
332
- const { Idempotent: IdempotentMiddleware } = await Promise.resolve().then(() => __importStar(require('../middleware/idempotency')));
333
- const handler = IdempotentMiddleware(options);
334
- return handler(req, res, next);
335
- };
336
- fn[METHOD_MIDDLEWARES].push(middlewareProxy);
337
- };
338
- }
339
- /**
340
- * Cache Decorator.
341
- * Caches responses for GET requests.
342
- *
343
- * Example:
344
- * @Get('/popular')
345
- * @Cache({ ttlMs: 60000 })
346
- * getPopular() {}
347
- */
348
- function Cache(options) {
349
- return function (target, contextOrPropertyKey, descriptor) {
350
- const isStandard = typeof contextOrPropertyKey === 'object' && contextOrPropertyKey !== null;
351
- const fn = isStandard ? target : descriptor.value;
352
- fn[METHOD_MIDDLEWARES] = fn[METHOD_MIDDLEWARES] || [];
353
- const opts = options;
354
- // Defer import to avoid circular dependencies
355
- const middlewareProxy = async (req, res, next) => {
356
- const { cacheMiddleware } = await Promise.resolve().then(() => __importStar(require('../middleware/cache')));
357
- const handler = cacheMiddleware(opts);
358
- return handler(req, res, next);
359
- };
360
- fn[METHOD_MIDDLEWARES].push(middlewareProxy);
361
- };
362
- }
363
- // ─── Custom HTTP Status / Header Response Decorators ────────────────────────
364
- /**
365
- * Defines a custom HTTP status code for a successful response.
366
- *
367
- * Example:
368
- *
369
- * @Post('/')
370
- * @HttpCode(201)
371
- * create() {}
372
- *
373
- * @param {number} code HTTP Status code
374
- * @public
375
- */
376
- function HttpCode(code) {
377
- return function (target, contextOrPropertyKey, descriptor) {
378
- const isStandard = typeof contextOrPropertyKey === 'object' && contextOrPropertyKey !== null;
379
- const fn = isStandard ? target : descriptor.value;
380
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
381
- fn[ROUTE_METADATA_PROP].httpCode = code;
382
- };
383
- }
384
- function Header(name, value) {
385
- return function (target, contextOrPropertyKey, descriptor) {
386
- const isStandard = typeof contextOrPropertyKey === 'object' && contextOrPropertyKey !== null;
387
- const fn = isStandard ? target : descriptor.value;
388
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
389
- fn[ROUTE_METADATA_PROP].headers = fn[ROUTE_METADATA_PROP].headers || {};
390
- fn[ROUTE_METADATA_PROP].headers[name] = value;
391
- };
392
- }
393
- /**
394
- * Defines the response schema for OpenAPI generation.
395
- *
396
- * Example:
397
- *
398
- * @Get('/')
399
- * @Returns(v.object({ id: v.string() }))
400
- * getUser() {}
401
- *
402
- * @param {RouteSchema['response']} schema The response schema
403
- * @public
404
- */
405
- function Returns(schema) {
406
- return function (target, contextOrPropertyKey, descriptor) {
407
- const isStandard = typeof contextOrPropertyKey === 'object' && contextOrPropertyKey !== null;
408
- const fn = isStandard ? target : descriptor.value;
409
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
410
- fn[ROUTE_METADATA_PROP].responseSchema = schema;
411
- };
412
- }
413
- // ─── Guards / Interceptors ──────────────────────────────────────────────────
414
- function UseGuards(...guards) {
415
- return function (target, contextOrPropertyKey, _descriptor) {
416
- if (typeof contextOrPropertyKey === 'object' &&
417
- contextOrPropertyKey !== null) {
418
- const context = contextOrPropertyKey;
419
- if (context.kind === 'class') {
420
- target.prototype[LIFECYCLE_METADATA_PROP] =
421
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
422
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards =
423
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards || [];
424
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards.push(...guards);
425
- }
426
- else if (context.kind === 'method') {
427
- ;
428
- target[LIFECYCLE_METADATA_PROP] =
429
- target[LIFECYCLE_METADATA_PROP] || {};
430
- target[LIFECYCLE_METADATA_PROP].guards =
431
- target[LIFECYCLE_METADATA_PROP].guards || [];
432
- target[LIFECYCLE_METADATA_PROP].guards.push(...guards);
433
- }
434
- }
435
- else {
436
- if (typeof target === 'function' && !contextOrPropertyKey) {
437
- // Legacy class decorator
438
- target.prototype[LIFECYCLE_METADATA_PROP] =
439
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
440
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards =
441
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards || [];
442
- target.prototype[LIFECYCLE_METADATA_PROP]._classGuards.push(...guards);
443
- }
444
- else {
445
- // Legacy method decorator
446
- const fn = target[contextOrPropertyKey];
447
- fn[LIFECYCLE_METADATA_PROP] = fn[LIFECYCLE_METADATA_PROP] || {};
448
- fn[LIFECYCLE_METADATA_PROP].guards =
449
- fn[LIFECYCLE_METADATA_PROP].guards || [];
450
- fn[LIFECYCLE_METADATA_PROP].guards.push(...guards);
451
- }
452
- }
453
- };
454
- }
455
- function UseInterceptors(...interceptors) {
456
- return function (target, contextOrPropertyKey, _descriptor) {
457
- if (typeof contextOrPropertyKey === 'object' &&
458
- contextOrPropertyKey !== null) {
459
- const context = contextOrPropertyKey;
460
- if (context.kind === 'class') {
461
- target.prototype[LIFECYCLE_METADATA_PROP] =
462
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
463
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors =
464
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors || [];
465
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors.push(...interceptors);
466
- }
467
- else if (context.kind === 'method') {
468
- ;
469
- target[LIFECYCLE_METADATA_PROP] =
470
- target[LIFECYCLE_METADATA_PROP] || {};
471
- target[LIFECYCLE_METADATA_PROP].interceptors =
472
- target[LIFECYCLE_METADATA_PROP].interceptors || [];
473
- target[LIFECYCLE_METADATA_PROP].interceptors.push(...interceptors);
474
- }
475
- }
476
- else {
477
- if (typeof target === 'function' && !contextOrPropertyKey) {
478
- // Legacy class decorator
479
- target.prototype[LIFECYCLE_METADATA_PROP] =
480
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
481
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors =
482
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors || [];
483
- target.prototype[LIFECYCLE_METADATA_PROP]._classInterceptors.push(...interceptors);
484
- }
485
- else {
486
- // Legacy method decorator
487
- const fn = target[contextOrPropertyKey];
488
- fn[LIFECYCLE_METADATA_PROP] = fn[LIFECYCLE_METADATA_PROP] || {};
489
- fn[LIFECYCLE_METADATA_PROP].interceptors =
490
- fn[LIFECYCLE_METADATA_PROP].interceptors || [];
491
- fn[LIFECYCLE_METADATA_PROP].interceptors.push(...interceptors);
492
- }
493
- }
494
- };
495
- }
496
- function UseFilters(...filters) {
497
- return function (target, contextOrPropertyKey, _descriptor) {
498
- if (typeof contextOrPropertyKey === 'object' &&
499
- contextOrPropertyKey !== null) {
500
- const context = contextOrPropertyKey;
501
- if (context.kind === 'class') {
502
- target.prototype[LIFECYCLE_METADATA_PROP] =
503
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
504
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters =
505
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters || [];
506
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters.push(...filters);
507
- }
508
- else if (context.kind === 'method') {
509
- ;
510
- target[LIFECYCLE_METADATA_PROP] =
511
- target[LIFECYCLE_METADATA_PROP] || {};
512
- target[LIFECYCLE_METADATA_PROP].filters =
513
- target[LIFECYCLE_METADATA_PROP].filters || [];
514
- target[LIFECYCLE_METADATA_PROP].filters.push(...filters);
515
- }
516
- }
517
- else {
518
- if (typeof target === 'function' && !contextOrPropertyKey) {
519
- // Legacy class decorator
520
- target.prototype[LIFECYCLE_METADATA_PROP] =
521
- target.prototype[LIFECYCLE_METADATA_PROP] || {};
522
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters =
523
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters || [];
524
- target.prototype[LIFECYCLE_METADATA_PROP]._classFilters.push(...filters);
525
- }
526
- else {
527
- // Legacy method decorator
528
- const fn = target[contextOrPropertyKey];
529
- fn[LIFECYCLE_METADATA_PROP] = fn[LIFECYCLE_METADATA_PROP] || {};
530
- fn[LIFECYCLE_METADATA_PROP].filters =
531
- fn[LIFECYCLE_METADATA_PROP].filters || [];
532
- fn[LIFECYCLE_METADATA_PROP].filters.push(...filters);
533
- }
534
- }
535
- };
536
- }
537
- // ─── Route Parameters ──────────────────────────────────────────────────────────
538
- function createParamDecorator(type, nameOrPipe, ...pipes) {
539
- return function (target, propertyKey, parameterIndex) {
540
- const isPipe = typeof nameOrPipe === 'function' ||
541
- (typeof nameOrPipe === 'object' && nameOrPipe !== null);
542
- const name = isPipe ? undefined : nameOrPipe;
543
- const allPipes = isPipe ? [nameOrPipe, ...pipes] : pipes;
544
- const fn = target[propertyKey];
545
- fn[PARAM_METADATA_PROP] = fn[PARAM_METADATA_PROP] || [];
546
- fn[PARAM_METADATA_PROP][parameterIndex] = { type, name, pipes: allPipes };
547
- };
548
- }
549
- const Param = (nameOrPipe, ...pipes) => createParamDecorator('param', nameOrPipe, ...pipes);
550
- exports.Param = Param;
551
- const Body = (nameOrPipe, ...pipes) => createParamDecorator('body', nameOrPipe, ...pipes);
552
- exports.Body = Body;
553
- const Headers = (nameOrPipe, ...pipes) => createParamDecorator('header', nameOrPipe, ...pipes);
554
- exports.Headers = Headers;
555
- const HostParam = (nameOrPipe, ...pipes) => createParamDecorator('host', nameOrPipe, ...pipes);
556
- exports.HostParam = HostParam;
557
- const Req = () => createParamDecorator('req');
558
- exports.Req = Req;
559
- const Socket = () => createParamDecorator('socket');
560
- exports.Socket = Socket;
561
- const Stream = () => createParamDecorator('stream');
562
- exports.Stream = Stream;
563
- const Session = () => createParamDecorator('session');
564
- exports.Session = Session;
565
- const Next = () => createParamDecorator('next');
566
- exports.Next = Next;
567
- const Ip = () => createParamDecorator('ip');
568
- exports.Ip = Ip;
569
- const UploadedFile = (nameOrPipe, ...pipes) => createParamDecorator('uploadedFile', nameOrPipe, ...pipes);
570
- exports.UploadedFile = UploadedFile;
571
- const UploadedFiles = (nameOrPipe, ...pipes) => createParamDecorator('uploadedFiles', nameOrPipe, ...pipes);
572
- exports.UploadedFiles = UploadedFiles;
573
- const Res = (options) => {
574
- return function (target, propertyKey, parameterIndex) {
575
- const fn = target[propertyKey];
576
- fn[PARAM_METADATA_PROP] = fn[PARAM_METADATA_PROP] || [];
577
- fn[PARAM_METADATA_PROP][parameterIndex] = { type: 'res' };
578
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
579
- fn[ROUTE_METADATA_PROP].manualRes = !options?.passthrough;
580
- };
581
- };
582
- exports.Res = Res;
583
- function Query(pathOrName, schemaOrPipe, ...pipes) {
584
- return function (target, contextOrPropertyKey, descriptorOrIndex) {
585
- const isParam = typeof descriptorOrIndex === 'number' ||
586
- (contextOrPropertyKey && contextOrPropertyKey.kind === 'parameter');
587
- if (isParam) {
588
- const isPipe = typeof pathOrName === 'function' ||
589
- (typeof pathOrName === 'object' && pathOrName !== null);
590
- const name = isPipe ? undefined : pathOrName;
591
- const pipesArray = isPipe ? [pathOrName] : [];
592
- if (schemaOrPipe &&
593
- (typeof schemaOrPipe === 'function' || typeof schemaOrPipe === 'object')) {
594
- pipesArray.push(schemaOrPipe);
595
- }
596
- pipesArray.push(...pipes);
597
- const parameterIndex = descriptorOrIndex;
598
- const fn = target[contextOrPropertyKey];
599
- fn[PARAM_METADATA_PROP] = fn[PARAM_METADATA_PROP] || [];
600
- fn[PARAM_METADATA_PROP][parameterIndex] = {
601
- type: 'query',
602
- name,
603
- pipes: pipesArray,
604
- };
605
- }
606
- else {
607
- const path = pathOrName || '';
608
- if (typeof contextOrPropertyKey === 'object' &&
609
- contextOrPropertyKey !== null &&
610
- 'name' in contextOrPropertyKey) {
611
- ;
612
- target[ROUTE_META] = {
613
- method: 'QUERY',
614
- path,
615
- schema: schemaOrPipe,
616
- };
617
- }
618
- else {
619
- const proto = typeof target === 'function' ? target.prototype : target;
620
- const name = contextOrPropertyKey || descriptorOrIndex?.name;
621
- if (!proto[exports.ROUTE_REGISTRY])
622
- proto[exports.ROUTE_REGISTRY] = [];
623
- proto[exports.ROUTE_REGISTRY].push({
624
- method: 'QUERY',
625
- path,
626
- schema: schemaOrPipe,
627
- handlerName: name,
628
- });
629
- }
630
- }
631
- };
632
- }
633
- const Redirect = (url, statusCode = 302) => {
634
- return function (target, propertyKey) {
635
- const fn = target[propertyKey];
636
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
637
- fn[ROUTE_METADATA_PROP].redirect = { url, statusCode };
638
- };
639
- };
640
- exports.Redirect = Redirect;
641
- const Permissions = (...permissions) => {
642
- return function (target, propertyKey) {
643
- if (propertyKey) {
644
- const fn = target[propertyKey];
645
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
646
- fn[ROUTE_METADATA_PROP].permissions = permissions;
647
- }
648
- else {
649
- const proto = typeof target === 'function' ? target.prototype : target;
650
- proto[ROUTE_METADATA_PROP] = proto[ROUTE_METADATA_PROP] || {};
651
- proto[ROUTE_METADATA_PROP].permissions = permissions;
652
- }
653
- };
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
654
15
  };
655
- exports.Permissions = Permissions;
656
- const Hosts = (...hosts) => {
657
- return function (target, propertyKey) {
658
- if (propertyKey) {
659
- const fn = target[propertyKey];
660
- fn[ROUTE_METADATA_PROP] = fn[ROUTE_METADATA_PROP] || {};
661
- fn[ROUTE_METADATA_PROP].hosts = hosts;
662
- }
663
- else {
664
- target.prototype[exports.CONTROLLER_HOST] = hosts;
665
- }
666
- };
667
- };
668
- exports.Hosts = Hosts;
669
- function Injectable(options) {
670
- return function (target, _context) {
671
- if (options?.scope) {
672
- target.prototype[Symbol.for('exisjs:scope')] = options.scope;
673
- }
674
- };
675
- }
676
- exports.SERVER_CONFIG = Symbol.for('exisjs:server_config');
677
- exports.GATEWAY_CONFIG = Symbol.for('exisjs:gateway_config');
678
- /**
679
- * Marks a class as a root Server module.
680
- */
681
- function Server(options) {
682
- return function (target, _context) {
683
- target.prototype[exports.SERVER_CONFIG] = options || {};
684
- };
685
- }
686
- /**
687
- * Marks a class as a Gateway module.
688
- */
689
- function Gateway(options) {
690
- return function (target, _context) {
691
- target.prototype[exports.GATEWAY_CONFIG] = options || {};
692
- };
693
- }
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./core"), exports);
19
+ __exportStar(require("./routing"), exports);
20
+ __exportStar(require("./params"), exports);
21
+ __exportStar(require("./middleware"), exports);
22
+ __exportStar(require("./response"), exports);
694
23
  //# sourceMappingURL=index.js.map