@vercube/core 0.0.22 → 0.0.24
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/README.md +10 -7
- package/dist/index.d.mts +16 -14
- package/dist/index.mjs +625 -758
- package/package.json +10 -6
package/dist/index.mjs
CHANGED
|
@@ -1,282 +1,40 @@
|
|
|
1
|
-
import "node:module";
|
|
2
1
|
import { BaseDecorator, Container, Inject, InjectOptional, createDecorator, initializeContainer } from "@vercube/di";
|
|
3
2
|
import { FastResponse, serve } from "srvx";
|
|
4
3
|
import { addRoute, createRouter, findRoute } from "rou3";
|
|
5
4
|
import { createReadStream } from "node:fs";
|
|
6
|
-
import { extname, join, normalize } from "node:path";
|
|
7
5
|
import { stat } from "node:fs/promises";
|
|
6
|
+
import { extname, join, normalize } from "node:path";
|
|
8
7
|
import { BaseLogger, Logger } from "@vercube/logger";
|
|
9
8
|
import { ConsoleProvider } from "@vercube/logger/drivers/ConsoleProvider";
|
|
10
9
|
import { loadConfig, setupDotenv } from "c12";
|
|
11
10
|
import { defu } from "defu";
|
|
12
11
|
|
|
13
|
-
//#region
|
|
14
|
-
var __create = Object.create;
|
|
15
|
-
var __defProp = Object.defineProperty;
|
|
16
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
17
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
19
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
-
var __commonJS = (cb, mod) => function() {
|
|
21
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
|
-
};
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
-
key = keys[i];
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
-
value: mod,
|
|
35
|
-
enumerable: true
|
|
36
|
-
}) : target, mod));
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.81.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js
|
|
40
|
-
var require_decorate = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.81.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js": ((exports, module) => {
|
|
41
|
-
function __decorate(decorators, target, key, desc) {
|
|
42
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
43
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
44
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
45
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
46
|
-
}
|
|
47
|
-
module.exports = __decorate, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
48
|
-
}) });
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/Services/Plugins/PluginsRegistry.ts
|
|
52
|
-
var import_decorate$18 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
53
|
-
var PluginsRegistry = class {
|
|
54
|
-
gContainer;
|
|
55
|
-
/** Holds the list of plugins */
|
|
56
|
-
fPlugins = /* @__PURE__ */ new Map();
|
|
57
|
-
/**
|
|
58
|
-
* Registers a plugin.
|
|
59
|
-
*
|
|
60
|
-
* @param {Plugin} plugin - The plugin to register.
|
|
61
|
-
* @param {unknown} options - The options to pass to the plugin.
|
|
62
|
-
*/
|
|
63
|
-
register(plugin, options) {
|
|
64
|
-
const instance = this.gContainer.resolve(plugin);
|
|
65
|
-
this.fPlugins.set(instance.name, {
|
|
66
|
-
instance,
|
|
67
|
-
options
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Gets the list of registered plugins.
|
|
72
|
-
*
|
|
73
|
-
* @returns {Plugin[]} The list of registered plugins.
|
|
74
|
-
*/
|
|
75
|
-
get plugins() {
|
|
76
|
-
return [...this.fPlugins.values()].map((plugin) => plugin.instance);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Resolves the plugins.
|
|
80
|
-
*
|
|
81
|
-
* @param {App} app - The application instance.
|
|
82
|
-
*/
|
|
83
|
-
async init(app) {
|
|
84
|
-
for (const { instance, options } of this.fPlugins.values()) await instance.use(app, options);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
(0, import_decorate$18.default)([Inject(Container)], PluginsRegistry.prototype, "gContainer", void 0);
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/Services/Hooks/HooksService.ts
|
|
91
|
-
/**
|
|
92
|
-
* This class is responsible for managing events.
|
|
93
|
-
*/
|
|
94
|
-
var HooksService = class {
|
|
95
|
-
fLastId = 0;
|
|
96
|
-
fHandlers = /* @__PURE__ */ new Map();
|
|
97
|
-
/**
|
|
98
|
-
* Registers listener for event of particular type. Everytime event is called, the listener
|
|
99
|
-
* will be executed.
|
|
100
|
-
*
|
|
101
|
-
* @param type type of event, simple class
|
|
102
|
-
* @param callback callback fired when event is triggered
|
|
103
|
-
* @returns unique ID for event listener, can be used to disable this listener
|
|
104
|
-
*/
|
|
105
|
-
on(type, callback) {
|
|
106
|
-
let handlersOfType = this.fHandlers.get(type);
|
|
107
|
-
if (!handlersOfType) {
|
|
108
|
-
handlersOfType = [];
|
|
109
|
-
this.fHandlers.set(type, handlersOfType);
|
|
110
|
-
}
|
|
111
|
-
const genId = this.fLastId++;
|
|
112
|
-
const handler = {
|
|
113
|
-
callback,
|
|
114
|
-
id: genId
|
|
115
|
-
};
|
|
116
|
-
handlersOfType.push(handler);
|
|
117
|
-
return {
|
|
118
|
-
__id: genId,
|
|
119
|
-
__type: type
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Waits for single event execution and removes the listener immediately after.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* this.gCart.addItem(product);
|
|
127
|
-
* await this.gEvents.waitFor(CartUpdatedEvent);
|
|
128
|
-
* console.log('here cart updated event is already called');
|
|
129
|
-
*
|
|
130
|
-
* @param type type of event to wait for
|
|
131
|
-
* @param timeout timeout param in ms - if event is not thrown until this time, it'll reject. passing null disables the timeout
|
|
132
|
-
* @returns promise with event data that resolves when event is finally called
|
|
133
|
-
*/
|
|
134
|
-
waitFor(type, timeout = 10 * 1e3) {
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
let waitTimeout;
|
|
137
|
-
const eventId = this.on(type, (data) => {
|
|
138
|
-
this.off(eventId);
|
|
139
|
-
resolve(data);
|
|
140
|
-
if (waitTimeout) clearTimeout(waitTimeout);
|
|
141
|
-
});
|
|
142
|
-
if (timeout !== null) waitTimeout = setTimeout(() => {
|
|
143
|
-
this.off(eventId);
|
|
144
|
-
reject(/* @__PURE__ */ new Error(`Waiting for event timeout - ${type.name}`));
|
|
145
|
-
}, timeout);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Removes listener from particular event.
|
|
150
|
-
* @param eventId eventId returned from .on() method.
|
|
151
|
-
* @throws Error if event was not registered
|
|
152
|
-
*/
|
|
153
|
-
off(eventId) {
|
|
154
|
-
const type = eventId.__type;
|
|
155
|
-
const handlersOfType = this.fHandlers.get(type);
|
|
156
|
-
if (!handlersOfType) throw new Error("Trying to unbind event that was not bound.");
|
|
157
|
-
const index = handlersOfType.findIndex((handler) => handler.id === eventId.__id);
|
|
158
|
-
if (index === -1) throw new Error("Trying to unbind event that was not bound.");
|
|
159
|
-
handlersOfType.splice(index, 1);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Triggers event, calling all listener callbacks. Will return Promise of number,
|
|
163
|
-
* that is resolved when all asynchronous listeners are called.
|
|
164
|
-
* @param type type of trigger, simple class
|
|
165
|
-
* @param data data which will be passed to listeners, based on event class
|
|
166
|
-
* @return number of listeners that were notified
|
|
167
|
-
*/
|
|
168
|
-
async trigger(type, data) {
|
|
169
|
-
const handlersOfType = this.fHandlers.get(type);
|
|
170
|
-
if (!handlersOfType) return 0;
|
|
171
|
-
const toProcessHandlers = [...handlersOfType];
|
|
172
|
-
const promises = toProcessHandlers.map((handler) => {
|
|
173
|
-
const instance = this.objectToClass(type, data);
|
|
174
|
-
const result = handler.callback(instance);
|
|
175
|
-
return result instanceof Promise ? result : Promise.resolve();
|
|
176
|
-
});
|
|
177
|
-
await Promise.all(promises);
|
|
178
|
-
return toProcessHandlers.length;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Converts plain object to it's class equivalent.
|
|
182
|
-
* It's NOT class-transformer, it performs basic key assigment.
|
|
183
|
-
*
|
|
184
|
-
* @param ClassConstructor event constructor
|
|
185
|
-
* @param data event data to be mapped to constructor
|
|
186
|
-
* @return class type of event
|
|
187
|
-
*/
|
|
188
|
-
objectToClass(ClassConstructor, data) {
|
|
189
|
-
const instance = new ClassConstructor();
|
|
190
|
-
if (data) for (const key of Object.keys(data)) {
|
|
191
|
-
const rawInstance = instance;
|
|
192
|
-
const rawData = data;
|
|
193
|
-
rawInstance[key] = rawData[key];
|
|
194
|
-
}
|
|
195
|
-
return instance;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/Hooks/Router/RouterBeforeInitHook.ts
|
|
201
|
-
var RouterBeforeInitHook = class {};
|
|
202
|
-
|
|
203
|
-
//#endregion
|
|
204
|
-
//#region src/Hooks/Router/RouterAfterInitHook.ts
|
|
205
|
-
var RouterAfterInitHook = class {};
|
|
206
|
-
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/Services/Router/Router.ts
|
|
209
|
-
var import_decorate$17 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
12
|
+
//#region src/Services/Config/RuntimeConfig.ts
|
|
210
13
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* This class provides functionality to initialize the router,
|
|
214
|
-
* register routes, and resolve incoming requests to their
|
|
215
|
-
* appropriate handlers.
|
|
14
|
+
* RuntimeConfig class manages the runtime configuration for the Vercube application.
|
|
15
|
+
* This class provides a centralized way to access and modify runtime configuration settings.
|
|
216
16
|
*/
|
|
217
|
-
var
|
|
218
|
-
/**
|
|
219
|
-
* Service for triggering application hooks
|
|
220
|
-
*/
|
|
221
|
-
gHooksService;
|
|
17
|
+
var RuntimeConfig = class {
|
|
222
18
|
/**
|
|
223
|
-
*
|
|
19
|
+
* Private field to store the runtime configuration object.
|
|
224
20
|
* @private
|
|
225
21
|
*/
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Registers a new route in the router
|
|
229
|
-
*
|
|
230
|
-
* @param {RouterTypes.Route} route - The route configuration to add
|
|
231
|
-
* @throws {Error} If router is not initialized
|
|
232
|
-
*/
|
|
233
|
-
addRoute(route) {
|
|
234
|
-
if (!this.fRouterContext) throw new Error("Router not initialized. Please call init() before adding routes.");
|
|
235
|
-
addRoute(this.fRouterContext, route.method.toUpperCase(), route.path, route.handler);
|
|
236
|
-
}
|
|
22
|
+
fRuntimeConfig;
|
|
237
23
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* This method creates a new router context and triggers
|
|
241
|
-
* the before and after initialization hooks.
|
|
24
|
+
* Gets the current runtime configuration.
|
|
25
|
+
* @returns {ConfigTypes.CreateRuntimeConfig<T> | undefined} The current runtime configuration object.
|
|
242
26
|
*/
|
|
243
|
-
|
|
244
|
-
this.
|
|
245
|
-
this.fRouterContext = createRouter();
|
|
246
|
-
this.gHooksService.trigger(RouterAfterInitHook);
|
|
27
|
+
get runtimeConfig() {
|
|
28
|
+
return this.fRuntimeConfig;
|
|
247
29
|
}
|
|
248
30
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* @param {RouterTypes.RouteFind} route - The route to resolve
|
|
252
|
-
* @returns {RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined} The matched route or undefined if no match found
|
|
31
|
+
* Sets the runtime configuration.
|
|
32
|
+
* @param {ConfigTypes.CreateRuntimeConfig<T>} value - The new runtime configuration object to set.
|
|
253
33
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
try {
|
|
257
|
-
url = new URL(route.path).pathname;
|
|
258
|
-
} catch {}
|
|
259
|
-
return findRoute(this.fRouterContext, route.method.toUpperCase(), url);
|
|
34
|
+
set runtimeConfig(value) {
|
|
35
|
+
this.fRuntimeConfig = value;
|
|
260
36
|
}
|
|
261
37
|
};
|
|
262
|
-
(0, import_decorate$17.default)([Inject(HooksService)], Router.prototype, "gHooksService", void 0);
|
|
263
|
-
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/Resolvers/RouterParam.ts
|
|
266
|
-
/**
|
|
267
|
-
* Resolves a router parameter from the event object
|
|
268
|
-
* @param param - The parameter name to resolve from the router event
|
|
269
|
-
* @param event - The router event object containing parameters
|
|
270
|
-
* @returns The resolved parameter value if it exists, null otherwise
|
|
271
|
-
* @example
|
|
272
|
-
* ```typescript
|
|
273
|
-
* const value = resolveRouterParam('id', routerEvent);
|
|
274
|
-
* // Returns the 'id' parameter value from routerEvent.params or null
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
function resolveRouterParam(param, event) {
|
|
278
|
-
return event.params?.[param] ?? null;
|
|
279
|
-
}
|
|
280
38
|
|
|
281
39
|
//#endregion
|
|
282
40
|
//#region src/Errors/HttpError.ts
|
|
@@ -305,46 +63,80 @@ var HttpError = class HttpError extends Error {
|
|
|
305
63
|
};
|
|
306
64
|
|
|
307
65
|
//#endregion
|
|
308
|
-
//#region src/Errors/Http/
|
|
66
|
+
//#region src/Errors/Http/NotFoundError.ts
|
|
309
67
|
/**
|
|
310
|
-
* Represents a
|
|
68
|
+
* Represents a Not Found error (HTTP 404).
|
|
311
69
|
* @extends {HttpError}
|
|
312
70
|
*/
|
|
313
|
-
var
|
|
71
|
+
var NotFoundError = class NotFoundError extends HttpError {
|
|
314
72
|
/**
|
|
315
73
|
* The name of the error.
|
|
316
74
|
* @type {string}
|
|
317
75
|
*/
|
|
318
|
-
name = "
|
|
76
|
+
name = "NotFoundError";
|
|
319
77
|
/**
|
|
320
|
-
* Creates an instance of
|
|
78
|
+
* Creates an instance of NotFoundError.
|
|
321
79
|
* @param {string} [message] - The error message.
|
|
322
80
|
*/
|
|
323
|
-
constructor(message
|
|
324
|
-
super(
|
|
325
|
-
Object.setPrototypeOf(this,
|
|
81
|
+
constructor(message) {
|
|
82
|
+
super(404);
|
|
83
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
326
84
|
if (message) this.message = message;
|
|
327
|
-
if (errors) this.errors = errors;
|
|
328
85
|
}
|
|
329
86
|
};
|
|
330
87
|
|
|
331
88
|
//#endregion
|
|
332
|
-
//#region src/
|
|
89
|
+
//#region src/Services/ErrorHandler/ErrorHandlerProvider.ts
|
|
333
90
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* @
|
|
338
|
-
*
|
|
339
|
-
|
|
91
|
+
* Abstract class representing an error handler provider
|
|
92
|
+
* Provides a common interface for different error handler implementations
|
|
93
|
+
*
|
|
94
|
+
* @abstract
|
|
95
|
+
* @class ErrorHandlerProvider
|
|
96
|
+
*/
|
|
97
|
+
var ErrorHandlerProvider = class {};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/Errors/Http/BadRequestError.ts
|
|
101
|
+
/**
|
|
102
|
+
* Represents a Bad Request error (HTTP 400).
|
|
103
|
+
* @extends {HttpError}
|
|
104
|
+
*/
|
|
105
|
+
var BadRequestError = class BadRequestError extends HttpError {
|
|
106
|
+
/**
|
|
107
|
+
* The name of the error.
|
|
108
|
+
* @type {string}
|
|
109
|
+
*/
|
|
110
|
+
name = "BadRequestError";
|
|
111
|
+
/**
|
|
112
|
+
* Creates an instance of BadRequestError.
|
|
113
|
+
* @param {string} [message] - The error message.
|
|
114
|
+
*/
|
|
115
|
+
constructor(message, errors) {
|
|
116
|
+
super(400);
|
|
117
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
118
|
+
if (message) this.message = message;
|
|
119
|
+
if (errors) this.errors = errors;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/Resolvers/Body.ts
|
|
125
|
+
/**
|
|
126
|
+
* Resolves and parses the request body from a RouterEvent.
|
|
127
|
+
*
|
|
128
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request to process
|
|
129
|
+
* @returns {Promise<unknown>} A promise that resolves to:
|
|
130
|
+
* - The parsed JSON body if the request contains valid JSON
|
|
131
|
+
* - undefined if the request body is empty
|
|
340
132
|
* @throws {BadRequestError} If the request body contains invalid JSON
|
|
341
|
-
*
|
|
133
|
+
*
|
|
342
134
|
* @example
|
|
343
135
|
* const body = await resolveRequestBody(event);
|
|
344
136
|
* if (body) {
|
|
345
137
|
* // Process the parsed body
|
|
346
138
|
* }
|
|
347
|
-
*
|
|
139
|
+
*
|
|
348
140
|
* @remarks
|
|
349
141
|
* - Currently only supports JSON content type
|
|
350
142
|
* - Returns undefined for empty request bodies
|
|
@@ -352,7 +144,7 @@ var BadRequestError = class BadRequestError extends HttpError {
|
|
|
352
144
|
*/
|
|
353
145
|
async function resolveRequestBody(event) {
|
|
354
146
|
const text = await event.request.text();
|
|
355
|
-
if (!text) return
|
|
147
|
+
if (!text) return;
|
|
356
148
|
try {
|
|
357
149
|
return JSON.parse(text);
|
|
358
150
|
} catch {
|
|
@@ -360,6 +152,26 @@ async function resolveRequestBody(event) {
|
|
|
360
152
|
}
|
|
361
153
|
}
|
|
362
154
|
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/Resolvers/Headers.ts
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves a specific header value from the request
|
|
159
|
+
* @param {string} header - The name of the header to retrieve
|
|
160
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request
|
|
161
|
+
* @returns {string | null} The header value if found, null otherwise
|
|
162
|
+
*/
|
|
163
|
+
function getRequestHeader(header, event) {
|
|
164
|
+
return event.request.headers.get(header);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves all headers from the request
|
|
168
|
+
* @param {RouterTypes.RouterEvent} event - The router event containing the request
|
|
169
|
+
* @returns {Headers} The complete Headers object from the request
|
|
170
|
+
*/
|
|
171
|
+
function getRequestHeaders(event) {
|
|
172
|
+
return event.request.headers;
|
|
173
|
+
}
|
|
174
|
+
|
|
363
175
|
//#endregion
|
|
364
176
|
//#region src/Resolvers/Query.ts
|
|
365
177
|
/**
|
|
@@ -369,8 +181,7 @@ async function resolveRequestBody(event) {
|
|
|
369
181
|
* @returns The value of the query parameter if found, null otherwise
|
|
370
182
|
*/
|
|
371
183
|
function resolveQueryParam(name, event) {
|
|
372
|
-
|
|
373
|
-
return url.searchParams.get(name);
|
|
184
|
+
return new URL(event.request.url).searchParams.get(name);
|
|
374
185
|
}
|
|
375
186
|
/**
|
|
376
187
|
* Resolves all query parameters from the URL of a router event
|
|
@@ -385,23 +196,20 @@ function resolveQueryParams(event) {
|
|
|
385
196
|
}
|
|
386
197
|
|
|
387
198
|
//#endregion
|
|
388
|
-
//#region src/Resolvers/
|
|
389
|
-
/**
|
|
390
|
-
* Retrieves a specific header value from the request
|
|
391
|
-
* @param {string} header - The name of the header to retrieve
|
|
392
|
-
* @param {RouterTypes.RouterEvent} event - The router event containing the request
|
|
393
|
-
* @returns {string | null} The header value if found, null otherwise
|
|
394
|
-
*/
|
|
395
|
-
function getRequestHeader(header, event) {
|
|
396
|
-
return event.request.headers.get(header);
|
|
397
|
-
}
|
|
199
|
+
//#region src/Resolvers/RouterParam.ts
|
|
398
200
|
/**
|
|
399
|
-
*
|
|
400
|
-
* @param
|
|
401
|
-
* @
|
|
201
|
+
* Resolves a router parameter from the event object
|
|
202
|
+
* @param param - The parameter name to resolve from the router event
|
|
203
|
+
* @param event - The router event object containing parameters
|
|
204
|
+
* @returns The resolved parameter value if it exists, null otherwise
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const value = resolveRouterParam('id', routerEvent);
|
|
208
|
+
* // Returns the 'id' parameter value from routerEvent.params or null
|
|
209
|
+
* ```
|
|
402
210
|
*/
|
|
403
|
-
function
|
|
404
|
-
return event.
|
|
211
|
+
function resolveRouterParam(param, event) {
|
|
212
|
+
return event.params?.[param] ?? null;
|
|
405
213
|
}
|
|
406
214
|
|
|
407
215
|
//#endregion
|
|
@@ -448,7 +256,7 @@ var MetadataResolver = class {
|
|
|
448
256
|
* Resolves an argument for a given event.
|
|
449
257
|
*
|
|
450
258
|
* @param {MetadataTypes.Arg} arg - The argument to resolve.
|
|
451
|
-
*
|
|
259
|
+
*
|
|
452
260
|
* @return {unknown} The resolved argument.
|
|
453
261
|
* @private
|
|
454
262
|
*/
|
|
@@ -477,27 +285,22 @@ var MetadataResolver = class {
|
|
|
477
285
|
* @public
|
|
478
286
|
*/
|
|
479
287
|
resolveMiddlewares(ctx, propertyName) {
|
|
480
|
-
|
|
481
|
-
return middlewares.sort((a) => a.target === "__global__" ? -1 : 1);
|
|
288
|
+
return (ctx?.__metadata?.__middlewares?.filter((m) => m.target === "__global__" || m.target === propertyName) ?? []).sort((a) => a.target === "__global__" ? -1 : 1);
|
|
482
289
|
}
|
|
483
290
|
};
|
|
484
291
|
|
|
485
292
|
//#endregion
|
|
486
|
-
//#region src/Services/
|
|
293
|
+
//#region src/Services/Middleware/BaseMiddleware.ts
|
|
487
294
|
/**
|
|
488
|
-
*
|
|
489
|
-
* Provides a common interface for different error handler implementations
|
|
490
|
-
*
|
|
491
|
-
* @abstract
|
|
492
|
-
* @class ErrorHandlerProvider
|
|
295
|
+
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
493
296
|
*/
|
|
494
|
-
var
|
|
297
|
+
var BaseMiddleware = class {};
|
|
495
298
|
|
|
496
299
|
//#endregion
|
|
497
300
|
//#region src/Services/Middleware/GlobalMiddlewareRegistry.ts
|
|
498
301
|
/**
|
|
499
302
|
* Manages global middleware registration and retrieval
|
|
500
|
-
*
|
|
303
|
+
*
|
|
501
304
|
* This class provides functionality to register and retrieve global middleware
|
|
502
305
|
* configurations. It allows for adding middleware with specific options and
|
|
503
306
|
* retrieving them in a standardized format.
|
|
@@ -506,7 +309,7 @@ var GlobalMiddlewareRegistry = class {
|
|
|
506
309
|
fMiddlewares = /* @__PURE__ */ new Set();
|
|
507
310
|
/**
|
|
508
311
|
* Retrieves all registered global middleware configurations
|
|
509
|
-
*
|
|
312
|
+
*
|
|
510
313
|
* @returns {MetadataTypes.Middleware[]} An array of middleware configurations
|
|
511
314
|
*/
|
|
512
315
|
get middlewares() {
|
|
@@ -518,7 +321,7 @@ var GlobalMiddlewareRegistry = class {
|
|
|
518
321
|
}
|
|
519
322
|
/**
|
|
520
323
|
* Registers a global middleware configuration
|
|
521
|
-
*
|
|
324
|
+
*
|
|
522
325
|
* @param {typeof BaseMiddleware<T, U>} middleware - The middleware class to register
|
|
523
326
|
* @param {GlobalMiddlewareParams<T>} opts - The middleware options
|
|
524
327
|
* @returns {void}
|
|
@@ -531,12 +334,20 @@ var GlobalMiddlewareRegistry = class {
|
|
|
531
334
|
}
|
|
532
335
|
};
|
|
533
336
|
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region \0@oxc-project+runtime@0.90.0/helpers/decorate.js
|
|
339
|
+
function __decorate(decorators, target, key, desc) {
|
|
340
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
341
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
342
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
343
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
344
|
+
}
|
|
345
|
+
|
|
534
346
|
//#endregion
|
|
535
347
|
//#region src/Services/Router/RequestHandler.ts
|
|
536
|
-
var import_decorate$16 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
537
348
|
/**
|
|
538
349
|
* Handles HTTP requests by preparing and executing route handlers with their associated middlewares
|
|
539
|
-
*
|
|
350
|
+
*
|
|
540
351
|
* The RequestHandler is responsible for:
|
|
541
352
|
* - Preparing route handlers with their metadata
|
|
542
353
|
* - Executing middleware chains (before and after)
|
|
@@ -551,131 +362,302 @@ var RequestHandler = class {
|
|
|
551
362
|
gGlobalMiddlewareRegistry;
|
|
552
363
|
/**
|
|
553
364
|
* Prepares a route handler by resolving its metadata and middlewares
|
|
554
|
-
*
|
|
365
|
+
*
|
|
555
366
|
* @param {RequestHandlerOptions} params - Configuration options for the handler
|
|
556
367
|
* @returns {RouterTypes.RouterHandler} A prepared handler with resolved metadata and middlewares
|
|
557
368
|
*/
|
|
558
|
-
prepareHandler(params) {
|
|
559
|
-
const { instance, propertyName } = params;
|
|
560
|
-
const prototype = Object.getPrototypeOf(instance);
|
|
561
|
-
const method = this.gMetadataResolver.resolveMethod(prototype, propertyName);
|
|
562
|
-
const middlewares = this.gMetadataResolver.resolveMiddlewares(prototype, propertyName);
|
|
563
|
-
const globalMiddlewares = this.gGlobalMiddlewareRegistry.middlewares;
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
369
|
+
prepareHandler(params) {
|
|
370
|
+
const { instance, propertyName } = params;
|
|
371
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
372
|
+
const method = this.gMetadataResolver.resolveMethod(prototype, propertyName);
|
|
373
|
+
const middlewares = this.gMetadataResolver.resolveMiddlewares(prototype, propertyName);
|
|
374
|
+
const globalMiddlewares = this.gGlobalMiddlewareRegistry.middlewares;
|
|
375
|
+
const resolvedMiddlewares = [...middlewares, ...globalMiddlewares].filter((m, index, self) => self.findIndex((t) => t.middleware === m.middleware) === index).map((m) => ({
|
|
376
|
+
...m,
|
|
377
|
+
middleware: this.gContainer.resolve(m.middleware)
|
|
378
|
+
}));
|
|
379
|
+
const beforeMiddlewares = resolvedMiddlewares.filter((m) => !!m.middleware.onRequest);
|
|
380
|
+
const afterMiddlewares = resolvedMiddlewares.filter((m) => !!m.middleware.onResponse);
|
|
381
|
+
beforeMiddlewares.sort((a, b) => (a?.priority ?? 999) - (b?.priority ?? 999));
|
|
382
|
+
afterMiddlewares.sort((a, b) => (a?.priority ?? 999) - (b?.priority ?? 999));
|
|
383
|
+
return {
|
|
384
|
+
instance,
|
|
385
|
+
propertyName,
|
|
386
|
+
args: method.args,
|
|
387
|
+
middlewares: {
|
|
388
|
+
beforeMiddlewares,
|
|
389
|
+
afterMiddlewares
|
|
390
|
+
},
|
|
391
|
+
actions: method.actions
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Processes an HTTP request through the middleware chain and route handler
|
|
396
|
+
*
|
|
397
|
+
* The request handling lifecycle:
|
|
398
|
+
* 1. Execute "before" middlewares
|
|
399
|
+
* 2. Apply route actions (status codes, redirects, etc.)
|
|
400
|
+
* 3. Resolve handler arguments
|
|
401
|
+
* 4. Execute the route handler
|
|
402
|
+
* 5. Execute "after" middlewares
|
|
403
|
+
* 6. Format and return the final response
|
|
404
|
+
*
|
|
405
|
+
* @param {Request} request - The incoming HTTP request
|
|
406
|
+
* @param {RouterTypes.RouteMatched<RouterTypes.RouterHandler>} route - The matched route with handler data
|
|
407
|
+
* @returns {Promise<Response>} The HTTP response
|
|
408
|
+
*/
|
|
409
|
+
async handleRequest(request, route) {
|
|
410
|
+
try {
|
|
411
|
+
const { instance, propertyName, actions = [], args = [], middlewares = {
|
|
412
|
+
beforeMiddlewares: [],
|
|
413
|
+
afterMiddlewares: []
|
|
414
|
+
} } = route.data;
|
|
415
|
+
let fakeResponse = new FastResponse(void 0, { headers: { "Content-Type": request.headers.get("Content-Type") ?? "application/json" } });
|
|
416
|
+
const resolvedArgs = args.length > 0 ? await this.gMetadataResolver.resolveArgs(args, {
|
|
417
|
+
...route,
|
|
418
|
+
request,
|
|
419
|
+
response: fakeResponse
|
|
420
|
+
}) : [];
|
|
421
|
+
if (middlewares.beforeMiddlewares.length > 0) for await (const hook of middlewares.beforeMiddlewares) try {
|
|
422
|
+
const hookResponse = await hook.middleware.onRequest?.(request, fakeResponse, {
|
|
423
|
+
middlewareArgs: hook.args,
|
|
424
|
+
methodArgs: resolvedArgs
|
|
425
|
+
});
|
|
426
|
+
if (hookResponse instanceof Response) return hookResponse;
|
|
427
|
+
} catch (error) {
|
|
428
|
+
const internalError = this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
429
|
+
if (internalError instanceof Response) return internalError;
|
|
430
|
+
}
|
|
431
|
+
for (const action of actions) {
|
|
432
|
+
const actionResponse = action.handler(request, fakeResponse);
|
|
433
|
+
if (actionResponse !== null) fakeResponse = this.processOverrideResponse(actionResponse, fakeResponse);
|
|
434
|
+
}
|
|
435
|
+
let handlerResponse = instance[propertyName].call(instance, ...resolvedArgs?.map((a) => a.resolved) ?? []);
|
|
436
|
+
if (handlerResponse instanceof Promise) handlerResponse = await handlerResponse;
|
|
437
|
+
if (middlewares.afterMiddlewares.length > 0) for await (const hook of middlewares.afterMiddlewares) try {
|
|
438
|
+
const hookResponse = await hook.middleware.onResponse?.(request, fakeResponse, handlerResponse);
|
|
439
|
+
if (hookResponse !== null) fakeResponse = this.processOverrideResponse(hookResponse, fakeResponse);
|
|
440
|
+
} catch (error) {
|
|
441
|
+
const internalError = this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
442
|
+
if (internalError instanceof Response) return internalError;
|
|
443
|
+
}
|
|
444
|
+
const body = fakeResponse?.body ?? JSON.stringify(handlerResponse);
|
|
445
|
+
return new Response(body, {
|
|
446
|
+
status: fakeResponse.status ?? 200,
|
|
447
|
+
statusText: fakeResponse.statusText ?? "OK",
|
|
448
|
+
headers: fakeResponse.headers
|
|
449
|
+
});
|
|
450
|
+
} catch (error) {
|
|
451
|
+
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Processes and merges response overrides from middlewares or actions
|
|
456
|
+
*
|
|
457
|
+
* This method handles different response formats:
|
|
458
|
+
* - If a full Response object is provided, it's used directly
|
|
459
|
+
* - If ResponseInit is provided, it's merged with the base response
|
|
460
|
+
*
|
|
461
|
+
* @param {Response | ResponseInit} response - The response or response options to apply
|
|
462
|
+
* @param {Response} [base] - The base response to extend (optional)
|
|
463
|
+
* @returns {Response} The processed response with applied overrides
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
processOverrideResponse(response, base) {
|
|
467
|
+
let fakeResponse = base ?? new FastResponse();
|
|
468
|
+
if (response != null && response instanceof FastResponse) return response;
|
|
469
|
+
else if (response !== null) {
|
|
470
|
+
const responseInit = response;
|
|
471
|
+
fakeResponse = new FastResponse(void 0, {
|
|
472
|
+
status: responseInit?.status ?? fakeResponse.status,
|
|
473
|
+
headers: responseInit?.headers ?? fakeResponse.headers,
|
|
474
|
+
statusText: responseInit?.statusText ?? fakeResponse.statusText
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return fakeResponse;
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
__decorate([Inject(MetadataResolver)], RequestHandler.prototype, "gMetadataResolver", void 0);
|
|
481
|
+
__decorate([Inject(Container)], RequestHandler.prototype, "gContainer", void 0);
|
|
482
|
+
__decorate([Inject(GlobalMiddlewareRegistry)], RequestHandler.prototype, "gGlobalMiddlewareRegistry", void 0);
|
|
483
|
+
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/Hooks/Router/RouterAfterInitHook.ts
|
|
486
|
+
var RouterAfterInitHook = class {};
|
|
487
|
+
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/Hooks/Router/RouterBeforeInitHook.ts
|
|
490
|
+
var RouterBeforeInitHook = class {};
|
|
491
|
+
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/Services/Hooks/HooksService.ts
|
|
494
|
+
/**
|
|
495
|
+
* This class is responsible for managing events.
|
|
496
|
+
*/
|
|
497
|
+
var HooksService = class {
|
|
498
|
+
fLastId = 0;
|
|
499
|
+
fHandlers = /* @__PURE__ */ new Map();
|
|
500
|
+
/**
|
|
501
|
+
* Registers listener for event of particular type. Everytime event is called, the listener
|
|
502
|
+
* will be executed.
|
|
503
|
+
*
|
|
504
|
+
* @param type type of event, simple class
|
|
505
|
+
* @param callback callback fired when event is triggered
|
|
506
|
+
* @returns unique ID for event listener, can be used to disable this listener
|
|
507
|
+
*/
|
|
508
|
+
on(type, callback) {
|
|
509
|
+
let handlersOfType = this.fHandlers.get(type);
|
|
510
|
+
if (!handlersOfType) {
|
|
511
|
+
handlersOfType = [];
|
|
512
|
+
this.fHandlers.set(type, handlersOfType);
|
|
513
|
+
}
|
|
514
|
+
const genId = this.fLastId++;
|
|
515
|
+
const handler = {
|
|
516
|
+
callback,
|
|
517
|
+
id: genId
|
|
518
|
+
};
|
|
519
|
+
handlersOfType.push(handler);
|
|
520
|
+
return {
|
|
521
|
+
__id: genId,
|
|
522
|
+
__type: type
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Waits for single event execution and removes the listener immediately after.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* this.gCart.addItem(product);
|
|
530
|
+
* await this.gEvents.waitFor(CartUpdatedEvent);
|
|
531
|
+
* console.log('here cart updated event is already called');
|
|
532
|
+
*
|
|
533
|
+
* @param type type of event to wait for
|
|
534
|
+
* @param timeout timeout param in ms - if event is not thrown until this time, it'll reject. passing null disables the timeout
|
|
535
|
+
* @returns promise with event data that resolves when event is finally called
|
|
536
|
+
*/
|
|
537
|
+
waitFor(type, timeout = 10 * 1e3) {
|
|
538
|
+
return new Promise((resolve, reject) => {
|
|
539
|
+
let waitTimeout;
|
|
540
|
+
const eventId = this.on(type, (data) => {
|
|
541
|
+
this.off(eventId);
|
|
542
|
+
resolve(data);
|
|
543
|
+
if (waitTimeout) clearTimeout(waitTimeout);
|
|
544
|
+
});
|
|
545
|
+
if (timeout !== null) waitTimeout = setTimeout(() => {
|
|
546
|
+
this.off(eventId);
|
|
547
|
+
reject(/* @__PURE__ */ new Error(`Waiting for event timeout - ${type.name}`));
|
|
548
|
+
}, timeout);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Removes listener from particular event.
|
|
553
|
+
* @param eventId eventId returned from .on() method.
|
|
554
|
+
* @throws Error if event was not registered
|
|
555
|
+
*/
|
|
556
|
+
off(eventId) {
|
|
557
|
+
const type = eventId.__type;
|
|
558
|
+
const handlersOfType = this.fHandlers.get(type);
|
|
559
|
+
if (!handlersOfType) throw new Error("Trying to unbind event that was not bound.");
|
|
560
|
+
const index = handlersOfType.findIndex((handler) => handler.id === eventId.__id);
|
|
561
|
+
if (index === -1) throw new Error("Trying to unbind event that was not bound.");
|
|
562
|
+
handlersOfType.splice(index, 1);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Triggers event, calling all listener callbacks. Will return Promise of number,
|
|
566
|
+
* that is resolved when all asynchronous listeners are called.
|
|
567
|
+
* @param type type of trigger, simple class
|
|
568
|
+
* @param data data which will be passed to listeners, based on event class
|
|
569
|
+
* @return number of listeners that were notified
|
|
570
|
+
*/
|
|
571
|
+
async trigger(type, data) {
|
|
572
|
+
const handlersOfType = this.fHandlers.get(type);
|
|
573
|
+
if (!handlersOfType) return 0;
|
|
574
|
+
const toProcessHandlers = [...handlersOfType];
|
|
575
|
+
const promises = toProcessHandlers.map((handler) => {
|
|
576
|
+
const instance = this.objectToClass(type, data);
|
|
577
|
+
const result = handler.callback(instance);
|
|
578
|
+
return result instanceof Promise ? result : Promise.resolve();
|
|
579
|
+
});
|
|
580
|
+
await Promise.all(promises);
|
|
581
|
+
return toProcessHandlers.length;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Converts plain object to it's class equivalent.
|
|
585
|
+
* It's NOT class-transformer, it performs basic key assigment.
|
|
586
|
+
*
|
|
587
|
+
* @param ClassConstructor event constructor
|
|
588
|
+
* @param data event data to be mapped to constructor
|
|
589
|
+
* @return class type of event
|
|
590
|
+
*/
|
|
591
|
+
objectToClass(ClassConstructor, data) {
|
|
592
|
+
const instance = new ClassConstructor();
|
|
593
|
+
if (data) for (const key of Object.keys(data)) {
|
|
594
|
+
const rawInstance = instance;
|
|
595
|
+
rawInstance[key] = data[key];
|
|
596
|
+
}
|
|
597
|
+
return instance;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region src/Services/Router/Router.ts
|
|
603
|
+
/**
|
|
604
|
+
* Router service responsible for managing application routes
|
|
605
|
+
*
|
|
606
|
+
* This class provides functionality to initialize the router,
|
|
607
|
+
* register routes, and resolve incoming requests to their
|
|
608
|
+
* appropriate handlers.
|
|
609
|
+
*/
|
|
610
|
+
var Router = class {
|
|
611
|
+
/**
|
|
612
|
+
* Service for triggering application hooks
|
|
613
|
+
*/
|
|
614
|
+
gHooksService;
|
|
615
|
+
/**
|
|
616
|
+
* Internal router context that stores all registered routes
|
|
617
|
+
* @private
|
|
618
|
+
*/
|
|
619
|
+
fRouterContext;
|
|
620
|
+
/**
|
|
621
|
+
* Registers a new route in the router
|
|
622
|
+
*
|
|
623
|
+
* @param {RouterTypes.Route} route - The route configuration to add
|
|
624
|
+
* @throws {Error} If router is not initialized
|
|
625
|
+
*/
|
|
626
|
+
addRoute(route) {
|
|
627
|
+
if (!this.fRouterContext) throw new Error("Router not initialized. Please call init() before adding routes.");
|
|
628
|
+
addRoute(this.fRouterContext, route.method.toUpperCase(), route.path, route.handler);
|
|
583
629
|
}
|
|
584
630
|
/**
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
* 2. Apply route actions (status codes, redirects, etc.)
|
|
590
|
-
* 3. Resolve handler arguments
|
|
591
|
-
* 4. Execute the route handler
|
|
592
|
-
* 5. Execute "after" middlewares
|
|
593
|
-
* 6. Format and return the final response
|
|
594
|
-
*
|
|
595
|
-
* @param {Request} request - The incoming HTTP request
|
|
596
|
-
* @param {RouterTypes.RouteMatched<RouterTypes.RouterHandler>} route - The matched route with handler data
|
|
597
|
-
* @returns {Promise<Response>} The HTTP response
|
|
631
|
+
* Initializes the router and triggers related hooks
|
|
632
|
+
*
|
|
633
|
+
* This method creates a new router context and triggers
|
|
634
|
+
* the before and after initialization hooks.
|
|
598
635
|
*/
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
afterMiddlewares: []
|
|
604
|
-
} } = route.data;
|
|
605
|
-
let fakeResponse = new FastResponse(void 0, { headers: { "Content-Type": request.headers.get("Content-Type") ?? "application/json" } });
|
|
606
|
-
const resolvedArgs = args.length > 0 ? await this.gMetadataResolver.resolveArgs(args, {
|
|
607
|
-
...route,
|
|
608
|
-
request,
|
|
609
|
-
response: fakeResponse
|
|
610
|
-
}) : [];
|
|
611
|
-
if (middlewares.beforeMiddlewares.length > 0) for await (const hook of middlewares.beforeMiddlewares) try {
|
|
612
|
-
const hookResponse = await hook.middleware.onRequest?.(request, fakeResponse, {
|
|
613
|
-
middlewareArgs: hook.args,
|
|
614
|
-
methodArgs: resolvedArgs
|
|
615
|
-
});
|
|
616
|
-
if (hookResponse instanceof Response) return hookResponse;
|
|
617
|
-
} catch (error) {
|
|
618
|
-
const internalError = this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
619
|
-
if (internalError instanceof Response) return internalError;
|
|
620
|
-
}
|
|
621
|
-
for (const action of actions) {
|
|
622
|
-
const actionResponse = action.handler(request, fakeResponse);
|
|
623
|
-
if (actionResponse !== null) fakeResponse = this.processOverrideResponse(actionResponse, fakeResponse);
|
|
624
|
-
}
|
|
625
|
-
let handlerResponse = instance[propertyName].call(instance, ...resolvedArgs?.map((a) => a.resolved) ?? []);
|
|
626
|
-
if (handlerResponse instanceof Promise) handlerResponse = await handlerResponse;
|
|
627
|
-
if (middlewares.afterMiddlewares.length > 0) for await (const hook of middlewares.afterMiddlewares) try {
|
|
628
|
-
const hookResponse = await hook.middleware.onResponse?.(request, fakeResponse, handlerResponse);
|
|
629
|
-
if (hookResponse !== null) fakeResponse = this.processOverrideResponse(hookResponse, fakeResponse);
|
|
630
|
-
} catch (error) {
|
|
631
|
-
const internalError = this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
632
|
-
if (internalError instanceof Response) return internalError;
|
|
633
|
-
}
|
|
634
|
-
const body = fakeResponse?.body ?? JSON.stringify(handlerResponse);
|
|
635
|
-
const response = new Response(body, {
|
|
636
|
-
status: fakeResponse.status ?? 200,
|
|
637
|
-
statusText: fakeResponse.statusText ?? "OK",
|
|
638
|
-
headers: fakeResponse.headers
|
|
639
|
-
});
|
|
640
|
-
return response;
|
|
641
|
-
} catch (error) {
|
|
642
|
-
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
643
|
-
}
|
|
636
|
+
initialize() {
|
|
637
|
+
this.gHooksService.trigger(RouterBeforeInitHook);
|
|
638
|
+
this.fRouterContext = createRouter();
|
|
639
|
+
this.gHooksService.trigger(RouterAfterInitHook);
|
|
644
640
|
}
|
|
645
641
|
/**
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
* - If ResponseInit is provided, it's merged with the base response
|
|
651
|
-
*
|
|
652
|
-
* @param {Response | ResponseInit} response - The response or response options to apply
|
|
653
|
-
* @param {Response} [base] - The base response to extend (optional)
|
|
654
|
-
* @returns {Response} The processed response with applied overrides
|
|
655
|
-
* @private
|
|
642
|
+
* Resolves a route based on the HTTP method and path
|
|
643
|
+
*
|
|
644
|
+
* @param {RouterTypes.RouteFind} route - The route to resolve
|
|
645
|
+
* @returns {RouterTypes.RouteMatched<RouterTypes.RouterHandler> | undefined} The matched route or undefined if no match found
|
|
656
646
|
*/
|
|
657
|
-
|
|
658
|
-
let
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
status: responseInit?.status ?? fakeResponse.status,
|
|
664
|
-
headers: responseInit?.headers ?? fakeResponse.headers,
|
|
665
|
-
statusText: responseInit?.statusText ?? fakeResponse.statusText
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
return fakeResponse;
|
|
647
|
+
resolve(route) {
|
|
648
|
+
let url = route.path;
|
|
649
|
+
try {
|
|
650
|
+
url = new URL(route.path).pathname;
|
|
651
|
+
} catch {}
|
|
652
|
+
return findRoute(this.fRouterContext, route.method.toUpperCase(), url);
|
|
669
653
|
}
|
|
670
654
|
};
|
|
671
|
-
(
|
|
672
|
-
(0, import_decorate$16.default)([Inject(Container)], RequestHandler.prototype, "gContainer", void 0);
|
|
673
|
-
(0, import_decorate$16.default)([Inject(GlobalMiddlewareRegistry)], RequestHandler.prototype, "gGlobalMiddlewareRegistry", void 0);
|
|
655
|
+
__decorate([Inject(HooksService)], Router.prototype, "gHooksService", void 0);
|
|
674
656
|
|
|
675
657
|
//#endregion
|
|
676
658
|
//#region src/Utils/Mine.ts
|
|
677
659
|
const mime = { getType(ext) {
|
|
678
|
-
|
|
660
|
+
return {
|
|
679
661
|
".html": "text/html",
|
|
680
662
|
".css": "text/css",
|
|
681
663
|
".js": "application/javascript",
|
|
@@ -686,15 +668,14 @@ const mime = { getType(ext) {
|
|
|
686
668
|
".gif": "image/gif",
|
|
687
669
|
".svg": "image/svg+xml",
|
|
688
670
|
".ico": "image/x-icon"
|
|
689
|
-
};
|
|
690
|
-
return types[ext] || null;
|
|
671
|
+
}[ext] || null;
|
|
691
672
|
} };
|
|
692
673
|
|
|
693
674
|
//#endregion
|
|
694
675
|
//#region src/Services/Router/StaticRequestHandler.ts
|
|
695
676
|
/**
|
|
696
677
|
* Handles serving static files over HTTP
|
|
697
|
-
*
|
|
678
|
+
*
|
|
698
679
|
* The StaticRequestHandler is responsible for:
|
|
699
680
|
* - Serving static files from configured directories
|
|
700
681
|
* - Setting appropriate content types and headers
|
|
@@ -708,7 +689,7 @@ var StaticRequestHandler = class {
|
|
|
708
689
|
fOptions;
|
|
709
690
|
/**
|
|
710
691
|
* Initializes the static server with the given options
|
|
711
|
-
*
|
|
692
|
+
*
|
|
712
693
|
* @param {ConfigTypes.ServerOptions['static']} options - The options for the static server
|
|
713
694
|
* @returns {void}
|
|
714
695
|
*/
|
|
@@ -717,7 +698,7 @@ var StaticRequestHandler = class {
|
|
|
717
698
|
}
|
|
718
699
|
/**
|
|
719
700
|
* Handles HTTP requests for static files
|
|
720
|
-
*
|
|
701
|
+
*
|
|
721
702
|
* @param {Request} request - The incoming HTTP request
|
|
722
703
|
* @returns {Promise<void | Response>} A promise that resolves to void or a Response object
|
|
723
704
|
*/
|
|
@@ -726,8 +707,7 @@ var StaticRequestHandler = class {
|
|
|
726
707
|
if (!dirs) return;
|
|
727
708
|
if (request.method !== "GET") return;
|
|
728
709
|
const url = new URL(request.url);
|
|
729
|
-
|
|
730
|
-
let relativePath = path;
|
|
710
|
+
let relativePath = normalize(url.pathname);
|
|
731
711
|
for (const dir of dirs) relativePath = relativePath.replace(dir, "");
|
|
732
712
|
for (const dir of dirs) {
|
|
733
713
|
const fullPath = join(process.cwd(), dir, relativePath);
|
|
@@ -742,7 +722,7 @@ var StaticRequestHandler = class {
|
|
|
742
722
|
}
|
|
743
723
|
/**
|
|
744
724
|
* Serves a static file and returns a Response object
|
|
745
|
-
*
|
|
725
|
+
*
|
|
746
726
|
* @param {string} path - The path to the file to serve
|
|
747
727
|
* @param {any} stats - The stats object for the file
|
|
748
728
|
* @returns {Promise<Response>} A promise that resolves to a Response object
|
|
@@ -766,10 +746,9 @@ var StaticRequestHandler = class {
|
|
|
766
746
|
|
|
767
747
|
//#endregion
|
|
768
748
|
//#region src/Services/HttpServer/HttpServer.ts
|
|
769
|
-
var import_decorate$15 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
770
749
|
/**
|
|
771
750
|
* HTTP server implementation for handling incoming web requests
|
|
772
|
-
*
|
|
751
|
+
*
|
|
773
752
|
* This class is responsible for:
|
|
774
753
|
* - Initializing and managing the HTTP server
|
|
775
754
|
* - Routing incoming requests to appropriate handlers
|
|
@@ -804,7 +783,7 @@ var HttpServer = class {
|
|
|
804
783
|
fPlugins = [];
|
|
805
784
|
/**
|
|
806
785
|
* Adds a plugin to the HTTP server
|
|
807
|
-
*
|
|
786
|
+
*
|
|
808
787
|
* @param {ServerPlugin} plugin - The plugin to add
|
|
809
788
|
* @returns {void}
|
|
810
789
|
*/
|
|
@@ -813,7 +792,7 @@ var HttpServer = class {
|
|
|
813
792
|
}
|
|
814
793
|
/**
|
|
815
794
|
* Initializes the HTTP server and starts listening for requests
|
|
816
|
-
*
|
|
795
|
+
*
|
|
817
796
|
* @returns {Promise<void>} A promise that resolves when the server is ready
|
|
818
797
|
*/
|
|
819
798
|
async initialize(config) {
|
|
@@ -835,7 +814,7 @@ var HttpServer = class {
|
|
|
835
814
|
}
|
|
836
815
|
/**
|
|
837
816
|
* Listens for incoming requests on the HTTP server
|
|
838
|
-
*
|
|
817
|
+
*
|
|
839
818
|
* @returns {Promise<void>} A promise that resolves when the server is ready to listen
|
|
840
819
|
*/
|
|
841
820
|
async listen() {
|
|
@@ -844,12 +823,12 @@ var HttpServer = class {
|
|
|
844
823
|
}
|
|
845
824
|
/**
|
|
846
825
|
* Processes an incoming HTTP request
|
|
847
|
-
*
|
|
826
|
+
*
|
|
848
827
|
* This method:
|
|
849
828
|
* 1. Resolves the route for the request
|
|
850
829
|
* 2. Returns a 404 response if no route is found
|
|
851
830
|
* 3. Delegates to the request handler for matched routes
|
|
852
|
-
*
|
|
831
|
+
*
|
|
853
832
|
* @param {Request} request - The incoming HTTP request
|
|
854
833
|
* @returns {Promise<Response>} The HTTP response
|
|
855
834
|
* @private
|
|
@@ -871,42 +850,70 @@ var HttpServer = class {
|
|
|
871
850
|
}
|
|
872
851
|
}
|
|
873
852
|
};
|
|
874
|
-
(
|
|
875
|
-
(
|
|
876
|
-
(
|
|
877
|
-
(
|
|
853
|
+
__decorate([Inject(Container)], HttpServer.prototype, "gContainer", void 0);
|
|
854
|
+
__decorate([Inject(Router)], HttpServer.prototype, "gRouter", void 0);
|
|
855
|
+
__decorate([Inject(RequestHandler)], HttpServer.prototype, "gRequestHandler", void 0);
|
|
856
|
+
__decorate([Inject(StaticRequestHandler)], HttpServer.prototype, "gStaticRequestHandler", void 0);
|
|
878
857
|
|
|
879
858
|
//#endregion
|
|
880
|
-
//#region src/Services/
|
|
859
|
+
//#region src/Services/Plugins/BasePlugin.ts
|
|
881
860
|
/**
|
|
882
|
-
*
|
|
883
|
-
* This class provides a centralized way to access and modify runtime configuration settings.
|
|
861
|
+
* Represents a Plugin.
|
|
884
862
|
*/
|
|
885
|
-
var
|
|
863
|
+
var BasePlugin = class {
|
|
886
864
|
/**
|
|
887
|
-
*
|
|
888
|
-
* @private
|
|
865
|
+
* The name of the plugin.
|
|
889
866
|
*/
|
|
890
|
-
|
|
867
|
+
name;
|
|
891
868
|
/**
|
|
892
|
-
*
|
|
893
|
-
* @
|
|
869
|
+
* Uses the plugin with the given app.
|
|
870
|
+
* @param {App} app - The application instance.
|
|
871
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves to void.
|
|
894
872
|
*/
|
|
895
|
-
|
|
896
|
-
|
|
873
|
+
use(app, options) {}
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/Services/Plugins/PluginsRegistry.ts
|
|
878
|
+
var PluginsRegistry = class {
|
|
879
|
+
gContainer;
|
|
880
|
+
/** Holds the list of plugins */
|
|
881
|
+
fPlugins = /* @__PURE__ */ new Map();
|
|
882
|
+
/**
|
|
883
|
+
* Registers a plugin.
|
|
884
|
+
*
|
|
885
|
+
* @param {Plugin} plugin - The plugin to register.
|
|
886
|
+
* @param {unknown} options - The options to pass to the plugin.
|
|
887
|
+
*/
|
|
888
|
+
register(plugin, options) {
|
|
889
|
+
const instance = this.gContainer.resolve(plugin);
|
|
890
|
+
if (!instance.name) throw new Error("Plugin must have a name");
|
|
891
|
+
this.fPlugins.set(instance.name, {
|
|
892
|
+
instance,
|
|
893
|
+
options
|
|
894
|
+
});
|
|
897
895
|
}
|
|
898
896
|
/**
|
|
899
|
-
*
|
|
900
|
-
*
|
|
897
|
+
* Gets the list of registered plugins.
|
|
898
|
+
*
|
|
899
|
+
* @returns {Plugin[]} The list of registered plugins.
|
|
901
900
|
*/
|
|
902
|
-
|
|
903
|
-
this.
|
|
901
|
+
get plugins() {
|
|
902
|
+
return [...this.fPlugins.values()].map((plugin) => plugin.instance);
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Resolves the plugins.
|
|
906
|
+
*
|
|
907
|
+
* @param {App} app - The application instance.
|
|
908
|
+
*/
|
|
909
|
+
async init(app) {
|
|
910
|
+
for (const { instance, options } of this.fPlugins.values()) await instance.use(app, options);
|
|
904
911
|
}
|
|
905
912
|
};
|
|
913
|
+
__decorate([Inject(Container)], PluginsRegistry.prototype, "gContainer", void 0);
|
|
906
914
|
|
|
907
915
|
//#endregion
|
|
908
916
|
//#region src/Common/App.ts
|
|
909
|
-
var import_decorate$14 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
910
917
|
/**
|
|
911
918
|
* Represents the main application class.
|
|
912
919
|
*/
|
|
@@ -986,7 +993,7 @@ var App = class {
|
|
|
986
993
|
/**
|
|
987
994
|
* Handles an incoming HTTP request.
|
|
988
995
|
* This method is an adapter for HttpServer.handleRequest method.
|
|
989
|
-
*
|
|
996
|
+
*
|
|
990
997
|
* @param {Request} request - The incoming HTTP request
|
|
991
998
|
* @returns {Promise<Response>} The HTTP response
|
|
992
999
|
*/
|
|
@@ -1002,42 +1009,11 @@ var App = class {
|
|
|
1002
1009
|
await this.gPluginsRegistry.init(this);
|
|
1003
1010
|
}
|
|
1004
1011
|
};
|
|
1005
|
-
(
|
|
1006
|
-
(
|
|
1007
|
-
(
|
|
1008
|
-
(
|
|
1009
|
-
(
|
|
1010
|
-
|
|
1011
|
-
//#endregion
|
|
1012
|
-
//#region src/Services/Validation/ValidationProvider.ts
|
|
1013
|
-
/**
|
|
1014
|
-
* Abstract class representing a validation provider
|
|
1015
|
-
* Provides a common interface for different validation implementations
|
|
1016
|
-
*
|
|
1017
|
-
* @abstract
|
|
1018
|
-
* @class ValidationProvider
|
|
1019
|
-
*/
|
|
1020
|
-
var ValidationProvider = class {};
|
|
1021
|
-
|
|
1022
|
-
//#endregion
|
|
1023
|
-
//#region src/Services/Validation/StandardSchemaValidationProvider.ts
|
|
1024
|
-
/**
|
|
1025
|
-
* StandardSchemaValidationProvider implements validation using StandardSchema schema validation
|
|
1026
|
-
* @see https://github.com/standard-schema/standard-schema
|
|
1027
|
-
* @class
|
|
1028
|
-
* @implements {ValidationProvider}
|
|
1029
|
-
*/
|
|
1030
|
-
var StandardSchemaValidationProvider = class {
|
|
1031
|
-
/**
|
|
1032
|
-
* Validates data against a schema
|
|
1033
|
-
* @param {ValidationTypes.Schema} schema - The schema to validate against
|
|
1034
|
-
* @param {ValidationTypes.Input} data - The data to validate
|
|
1035
|
-
* @return {ValidationTypes.Result | Promise<ValidationTypes.Result>} The validation result
|
|
1036
|
-
*/
|
|
1037
|
-
validate(schema, data) {
|
|
1038
|
-
return schema["~standard"].validate(data);
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1012
|
+
__decorate([Inject(Router)], App.prototype, "gRouter", void 0);
|
|
1013
|
+
__decorate([Inject(PluginsRegistry)], App.prototype, "gPluginsRegistry", void 0);
|
|
1014
|
+
__decorate([Inject(HttpServer)], App.prototype, "gHttpServer", void 0);
|
|
1015
|
+
__decorate([Inject(StaticRequestHandler)], App.prototype, "gStaticRequestHandler", void 0);
|
|
1016
|
+
__decorate([Inject(RuntimeConfig)], App.prototype, "gRuntimeConfig", void 0);
|
|
1041
1017
|
|
|
1042
1018
|
//#endregion
|
|
1043
1019
|
//#region src/Errors/Http/InternalServerError.ts
|
|
@@ -1064,7 +1040,6 @@ var InternalServerError = class InternalServerError extends HttpError {
|
|
|
1064
1040
|
|
|
1065
1041
|
//#endregion
|
|
1066
1042
|
//#region src/Services/ErrorHandler/DefaultErrorHandlerProvider.ts
|
|
1067
|
-
var import_decorate$13 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1068
1043
|
/**
|
|
1069
1044
|
* Default error handler provider
|
|
1070
1045
|
*
|
|
@@ -1073,20 +1048,51 @@ var import_decorate$13 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
|
1073
1048
|
var DefaultErrorHandlerProvider = class extends ErrorHandlerProvider {
|
|
1074
1049
|
gLogger;
|
|
1075
1050
|
/**
|
|
1076
|
-
* Handles an error that occurred during request processing
|
|
1077
|
-
*
|
|
1078
|
-
* @param error - The Error object containing error details
|
|
1079
|
-
* @returns Promise<Response> | Response - The response to be sent to the client
|
|
1051
|
+
* Handles an error that occurred during request processing
|
|
1052
|
+
*
|
|
1053
|
+
* @param error - The Error object containing error details
|
|
1054
|
+
* @returns Promise<Response> | Response - The response to be sent to the client
|
|
1055
|
+
*/
|
|
1056
|
+
handleError(error) {
|
|
1057
|
+
const _internalError = new InternalServerError(error?.message ?? "Internal server error");
|
|
1058
|
+
const status = error?.status ?? 500;
|
|
1059
|
+
if (error instanceof HttpError) return new FastResponse(JSON.stringify({ ...error }, void 0, 2), { status });
|
|
1060
|
+
this.gLogger.error(error);
|
|
1061
|
+
return new FastResponse(JSON.stringify({ ...error?.cause ?? _internalError }, void 0, 2), { status });
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
__decorate([Inject(Logger)], DefaultErrorHandlerProvider.prototype, "gLogger", void 0);
|
|
1065
|
+
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region src/Services/Validation/ValidationProvider.ts
|
|
1068
|
+
/**
|
|
1069
|
+
* Abstract class representing a validation provider
|
|
1070
|
+
* Provides a common interface for different validation implementations
|
|
1071
|
+
*
|
|
1072
|
+
* @abstract
|
|
1073
|
+
* @class ValidationProvider
|
|
1074
|
+
*/
|
|
1075
|
+
var ValidationProvider = class {};
|
|
1076
|
+
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/Services/Validation/StandardSchemaValidationProvider.ts
|
|
1079
|
+
/**
|
|
1080
|
+
* StandardSchemaValidationProvider implements validation using StandardSchema schema validation
|
|
1081
|
+
* @see https://github.com/standard-schema/standard-schema
|
|
1082
|
+
* @class
|
|
1083
|
+
* @implements {ValidationProvider}
|
|
1084
|
+
*/
|
|
1085
|
+
var StandardSchemaValidationProvider = class {
|
|
1086
|
+
/**
|
|
1087
|
+
* Validates data against a schema
|
|
1088
|
+
* @param {ValidationTypes.Schema} schema - The schema to validate against
|
|
1089
|
+
* @param {ValidationTypes.Input} data - The data to validate
|
|
1090
|
+
* @return {ValidationTypes.Result | Promise<ValidationTypes.Result>} The validation result
|
|
1080
1091
|
*/
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
const status = error?.status ?? 500;
|
|
1084
|
-
if (error instanceof HttpError) return new FastResponse(JSON.stringify({ ...error }, void 0, 2), { status });
|
|
1085
|
-
this.gLogger.error(error);
|
|
1086
|
-
return new FastResponse(JSON.stringify({ ...error?.cause ?? _internalError }, void 0, 2), { status });
|
|
1092
|
+
validate(schema, data) {
|
|
1093
|
+
return schema["~standard"].validate(data);
|
|
1087
1094
|
}
|
|
1088
1095
|
};
|
|
1089
|
-
(0, import_decorate$13.default)([Inject(Logger)], DefaultErrorHandlerProvider.prototype, "gLogger", void 0);
|
|
1090
1096
|
|
|
1091
1097
|
//#endregion
|
|
1092
1098
|
//#region src/Common/Container.ts
|
|
@@ -1217,7 +1223,6 @@ function defineConfig(config) {
|
|
|
1217
1223
|
|
|
1218
1224
|
//#endregion
|
|
1219
1225
|
//#region src/Middleware/ValidationMiddleware.ts
|
|
1220
|
-
var import_decorate$12 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1221
1226
|
/**
|
|
1222
1227
|
* Middleware for validating request data against a schema
|
|
1223
1228
|
* @class ValidationMiddleware
|
|
@@ -1228,6 +1233,7 @@ var import_decorate$12 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
|
1228
1233
|
* await middleware.use(event, { schema: myValidationSchema });
|
|
1229
1234
|
*/
|
|
1230
1235
|
var ValidationMiddleware = class {
|
|
1236
|
+
gLogger;
|
|
1231
1237
|
gValidationProvider;
|
|
1232
1238
|
/**
|
|
1233
1239
|
* Middleware function that processes the HTTP event
|
|
@@ -1239,7 +1245,7 @@ var ValidationMiddleware = class {
|
|
|
1239
1245
|
*/
|
|
1240
1246
|
async onRequest(request, response, args) {
|
|
1241
1247
|
if (!this.gValidationProvider) {
|
|
1242
|
-
|
|
1248
|
+
this.gLogger?.warn("ValidationMiddleware::ValidationProvider", "Validation provider is not registered");
|
|
1243
1249
|
return;
|
|
1244
1250
|
}
|
|
1245
1251
|
const validators = args.methodArgs?.filter((arg) => arg.validate && arg.validationSchema) ?? [];
|
|
@@ -1249,7 +1255,8 @@ var ValidationMiddleware = class {
|
|
|
1249
1255
|
}
|
|
1250
1256
|
}
|
|
1251
1257
|
};
|
|
1252
|
-
(
|
|
1258
|
+
__decorate([InjectOptional(Logger)], ValidationMiddleware.prototype, "gLogger", void 0);
|
|
1259
|
+
__decorate([InjectOptional(ValidationProvider)], ValidationMiddleware.prototype, "gValidationProvider", void 0);
|
|
1253
1260
|
|
|
1254
1261
|
//#endregion
|
|
1255
1262
|
//#region src/Utils/Utils.ts
|
|
@@ -1315,8 +1322,7 @@ var BodyDecorator = class extends BaseDecorator {
|
|
|
1315
1322
|
*/
|
|
1316
1323
|
created() {
|
|
1317
1324
|
const meta = initializeMetadata(this.prototype);
|
|
1318
|
-
|
|
1319
|
-
method.args.push({
|
|
1325
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
1320
1326
|
idx: this.propertyIndex,
|
|
1321
1327
|
type: "body",
|
|
1322
1328
|
validate: this.options?.validationSchema ? true : false,
|
|
@@ -1345,7 +1351,6 @@ function Body(options) {
|
|
|
1345
1351
|
|
|
1346
1352
|
//#endregion
|
|
1347
1353
|
//#region src/Decorators/Http/Connect.ts
|
|
1348
|
-
var import_decorate$11 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1349
1354
|
/**
|
|
1350
1355
|
* A decorator class for handling HTTP CONNECT requests.
|
|
1351
1356
|
*
|
|
@@ -1384,9 +1389,9 @@ var ConnectDecorator = class extends BaseDecorator {
|
|
|
1384
1389
|
});
|
|
1385
1390
|
}
|
|
1386
1391
|
};
|
|
1387
|
-
(
|
|
1388
|
-
(
|
|
1389
|
-
(
|
|
1392
|
+
__decorate([Inject(Router)], ConnectDecorator.prototype, "gRouter", void 0);
|
|
1393
|
+
__decorate([Inject(RequestHandler)], ConnectDecorator.prototype, "gRequestHandler", void 0);
|
|
1394
|
+
__decorate([Inject(MetadataResolver)], ConnectDecorator.prototype, "gMetadataResolver", void 0);
|
|
1390
1395
|
/**
|
|
1391
1396
|
* A factory function for creating a ConnectDecorator.
|
|
1392
1397
|
*
|
|
@@ -1423,7 +1428,6 @@ function Controller(path) {
|
|
|
1423
1428
|
|
|
1424
1429
|
//#endregion
|
|
1425
1430
|
//#region src/Decorators/Http/Delete.ts
|
|
1426
|
-
var import_decorate$10 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1427
1431
|
/**
|
|
1428
1432
|
* A decorator class for handling HTTP DELETE requests.
|
|
1429
1433
|
*
|
|
@@ -1462,9 +1466,9 @@ var DeleteDecorator = class extends BaseDecorator {
|
|
|
1462
1466
|
});
|
|
1463
1467
|
}
|
|
1464
1468
|
};
|
|
1465
|
-
(
|
|
1466
|
-
(
|
|
1467
|
-
(
|
|
1469
|
+
__decorate([Inject(Router)], DeleteDecorator.prototype, "gRouter", void 0);
|
|
1470
|
+
__decorate([Inject(RequestHandler)], DeleteDecorator.prototype, "gRequestHandler", void 0);
|
|
1471
|
+
__decorate([Inject(MetadataResolver)], DeleteDecorator.prototype, "gMetadataResolver", void 0);
|
|
1468
1472
|
/**
|
|
1469
1473
|
* A factory function for creating a DeleteDecorator.
|
|
1470
1474
|
*
|
|
@@ -1480,7 +1484,6 @@ function Delete(path) {
|
|
|
1480
1484
|
|
|
1481
1485
|
//#endregion
|
|
1482
1486
|
//#region src/Decorators/Http/Get.ts
|
|
1483
|
-
var import_decorate$9 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1484
1487
|
/**
|
|
1485
1488
|
* A decorator class for handling HTTP GET requests.
|
|
1486
1489
|
*
|
|
@@ -1519,9 +1522,9 @@ var GetDecorator = class extends BaseDecorator {
|
|
|
1519
1522
|
});
|
|
1520
1523
|
}
|
|
1521
1524
|
};
|
|
1522
|
-
(
|
|
1523
|
-
(
|
|
1524
|
-
(
|
|
1525
|
+
__decorate([Inject(Router)], GetDecorator.prototype, "gRouter", void 0);
|
|
1526
|
+
__decorate([Inject(RequestHandler)], GetDecorator.prototype, "gRequestHandler", void 0);
|
|
1527
|
+
__decorate([Inject(MetadataResolver)], GetDecorator.prototype, "gMetadataResolver", void 0);
|
|
1525
1528
|
/**
|
|
1526
1529
|
* A decorator function for handling HTTP GET requests.
|
|
1527
1530
|
*
|
|
@@ -1537,7 +1540,6 @@ function Get(path) {
|
|
|
1537
1540
|
|
|
1538
1541
|
//#endregion
|
|
1539
1542
|
//#region src/Decorators/Http/Head.ts
|
|
1540
|
-
var import_decorate$8 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1541
1543
|
/**
|
|
1542
1544
|
* A decorator class for handling HTTP HEAD requests.
|
|
1543
1545
|
*
|
|
@@ -1576,9 +1578,9 @@ var HeadDecorator = class extends BaseDecorator {
|
|
|
1576
1578
|
});
|
|
1577
1579
|
}
|
|
1578
1580
|
};
|
|
1579
|
-
(
|
|
1580
|
-
(
|
|
1581
|
-
(
|
|
1581
|
+
__decorate([Inject(Router)], HeadDecorator.prototype, "gRouter", void 0);
|
|
1582
|
+
__decorate([Inject(RequestHandler)], HeadDecorator.prototype, "gRequestHandler", void 0);
|
|
1583
|
+
__decorate([Inject(MetadataResolver)], HeadDecorator.prototype, "gMetadataResolver", void 0);
|
|
1582
1584
|
/**
|
|
1583
1585
|
* A factory function for creating a HeadDecorator.
|
|
1584
1586
|
*
|
|
@@ -1612,8 +1614,7 @@ var HeaderDecorator = class extends BaseDecorator {
|
|
|
1612
1614
|
*/
|
|
1613
1615
|
created() {
|
|
1614
1616
|
initializeMetadata(this.prototype);
|
|
1615
|
-
|
|
1616
|
-
method.args.push({
|
|
1617
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
1617
1618
|
idx: this.propertyIndex,
|
|
1618
1619
|
type: "header",
|
|
1619
1620
|
data: { name: this.options.name }
|
|
@@ -1654,8 +1655,7 @@ var HeadersDecorator = class extends BaseDecorator {
|
|
|
1654
1655
|
*/
|
|
1655
1656
|
created() {
|
|
1656
1657
|
initializeMetadata(this.prototype);
|
|
1657
|
-
|
|
1658
|
-
method.args.push({
|
|
1658
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
1659
1659
|
idx: this.propertyIndex,
|
|
1660
1660
|
type: "headers"
|
|
1661
1661
|
});
|
|
@@ -1675,7 +1675,6 @@ function Headers$1() {
|
|
|
1675
1675
|
|
|
1676
1676
|
//#endregion
|
|
1677
1677
|
//#region src/Decorators/Http/Options.ts
|
|
1678
|
-
var import_decorate$7 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1679
1678
|
/**
|
|
1680
1679
|
* A decorator class for handling HTTP OPTIONS requests.
|
|
1681
1680
|
*
|
|
@@ -1714,9 +1713,9 @@ var OptionsDecorator = class extends BaseDecorator {
|
|
|
1714
1713
|
});
|
|
1715
1714
|
}
|
|
1716
1715
|
};
|
|
1717
|
-
(
|
|
1718
|
-
(
|
|
1719
|
-
(
|
|
1716
|
+
__decorate([Inject(Router)], OptionsDecorator.prototype, "gRouter", void 0);
|
|
1717
|
+
__decorate([Inject(RequestHandler)], OptionsDecorator.prototype, "gRequestHandler", void 0);
|
|
1718
|
+
__decorate([Inject(MetadataResolver)], OptionsDecorator.prototype, "gMetadataResolver", void 0);
|
|
1720
1719
|
/**
|
|
1721
1720
|
* A factory function for creating an OptionsDecorator.
|
|
1722
1721
|
*
|
|
@@ -1732,7 +1731,6 @@ function Options(path) {
|
|
|
1732
1731
|
|
|
1733
1732
|
//#endregion
|
|
1734
1733
|
//#region src/Decorators/Http/Param.ts
|
|
1735
|
-
var import_decorate$6 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1736
1734
|
/**
|
|
1737
1735
|
* This class is responsible for managing parameter decorators.
|
|
1738
1736
|
*
|
|
@@ -1752,15 +1750,14 @@ var ParamDecorator = class extends BaseDecorator {
|
|
|
1752
1750
|
*/
|
|
1753
1751
|
created() {
|
|
1754
1752
|
initializeMetadata(this.prototype);
|
|
1755
|
-
|
|
1756
|
-
method.args.push({
|
|
1753
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
1757
1754
|
idx: this.propertyIndex,
|
|
1758
1755
|
type: "param",
|
|
1759
1756
|
data: { name: this.options.name }
|
|
1760
1757
|
});
|
|
1761
1758
|
}
|
|
1762
1759
|
};
|
|
1763
|
-
(
|
|
1760
|
+
__decorate([Inject(MetadataResolver)], ParamDecorator.prototype, "gMetadataResolver", void 0);
|
|
1764
1761
|
/**
|
|
1765
1762
|
* A factory function for creating a ParamDecorator.
|
|
1766
1763
|
*
|
|
@@ -1778,7 +1775,6 @@ function Param(name) {
|
|
|
1778
1775
|
|
|
1779
1776
|
//#endregion
|
|
1780
1777
|
//#region src/Decorators/Http/Patch.ts
|
|
1781
|
-
var import_decorate$5 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1782
1778
|
/**
|
|
1783
1779
|
* A decorator class for handling HTTP PATCH requests.
|
|
1784
1780
|
*
|
|
@@ -1817,9 +1813,9 @@ var PatchDecorator = class extends BaseDecorator {
|
|
|
1817
1813
|
});
|
|
1818
1814
|
}
|
|
1819
1815
|
};
|
|
1820
|
-
(
|
|
1821
|
-
(
|
|
1822
|
-
(
|
|
1816
|
+
__decorate([Inject(Router)], PatchDecorator.prototype, "gRouter", void 0);
|
|
1817
|
+
__decorate([Inject(RequestHandler)], PatchDecorator.prototype, "gRequestHandler", void 0);
|
|
1818
|
+
__decorate([Inject(MetadataResolver)], PatchDecorator.prototype, "gMetadataResolver", void 0);
|
|
1823
1819
|
/**
|
|
1824
1820
|
* A factory function for creating a PatchDecorator.
|
|
1825
1821
|
*
|
|
@@ -1835,7 +1831,6 @@ function Patch(path) {
|
|
|
1835
1831
|
|
|
1836
1832
|
//#endregion
|
|
1837
1833
|
//#region src/Decorators/Http/Post.ts
|
|
1838
|
-
var import_decorate$4 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1839
1834
|
/**
|
|
1840
1835
|
* A decorator class for handling HTTP POST requests.
|
|
1841
1836
|
*
|
|
@@ -1874,9 +1869,9 @@ var PostDecorator = class extends BaseDecorator {
|
|
|
1874
1869
|
});
|
|
1875
1870
|
}
|
|
1876
1871
|
};
|
|
1877
|
-
(
|
|
1878
|
-
(
|
|
1879
|
-
(
|
|
1872
|
+
__decorate([Inject(Router)], PostDecorator.prototype, "gRouter", void 0);
|
|
1873
|
+
__decorate([Inject(MetadataResolver)], PostDecorator.prototype, "gMetadataResolver", void 0);
|
|
1874
|
+
__decorate([Inject(RequestHandler)], PostDecorator.prototype, "gRequestHandler", void 0);
|
|
1880
1875
|
/**
|
|
1881
1876
|
* A factory function for creating a PostDecorator.
|
|
1882
1877
|
*
|
|
@@ -1892,7 +1887,6 @@ function Post(path) {
|
|
|
1892
1887
|
|
|
1893
1888
|
//#endregion
|
|
1894
1889
|
//#region src/Decorators/Http/Put.ts
|
|
1895
|
-
var import_decorate$3 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
1896
1890
|
/**
|
|
1897
1891
|
* A decorator class for handling HTTP PUT requests.
|
|
1898
1892
|
*
|
|
@@ -1931,9 +1925,9 @@ var PutDecorator = class extends BaseDecorator {
|
|
|
1931
1925
|
});
|
|
1932
1926
|
}
|
|
1933
1927
|
};
|
|
1934
|
-
(
|
|
1935
|
-
(
|
|
1936
|
-
(
|
|
1928
|
+
__decorate([Inject(Router)], PutDecorator.prototype, "gRouter", void 0);
|
|
1929
|
+
__decorate([Inject(RequestHandler)], PutDecorator.prototype, "gRequestHandler", void 0);
|
|
1930
|
+
__decorate([Inject(MetadataResolver)], PutDecorator.prototype, "gMetadataResolver", void 0);
|
|
1937
1931
|
/**
|
|
1938
1932
|
* A factory function for creating a PutDecorator.
|
|
1939
1933
|
*
|
|
@@ -1967,8 +1961,7 @@ var QueryParamDecorator = class extends BaseDecorator {
|
|
|
1967
1961
|
*/
|
|
1968
1962
|
created() {
|
|
1969
1963
|
const meta = initializeMetadata(this.prototype);
|
|
1970
|
-
|
|
1971
|
-
method.args.push({
|
|
1964
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
1972
1965
|
idx: this.propertyIndex,
|
|
1973
1966
|
type: "query-param",
|
|
1974
1967
|
data: { name: this.options.name },
|
|
@@ -2016,8 +2009,7 @@ var QueryParamsDecorator = class extends BaseDecorator {
|
|
|
2016
2009
|
*/
|
|
2017
2010
|
created() {
|
|
2018
2011
|
const meta = initializeMetadata(this.prototype);
|
|
2019
|
-
|
|
2020
|
-
method.args.push({
|
|
2012
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
2021
2013
|
idx: this.propertyIndex,
|
|
2022
2014
|
type: "query-params",
|
|
2023
2015
|
data: {},
|
|
@@ -2065,8 +2057,7 @@ var RequestDecorator = class extends BaseDecorator {
|
|
|
2065
2057
|
*/
|
|
2066
2058
|
created() {
|
|
2067
2059
|
initializeMetadata(this.prototype);
|
|
2068
|
-
|
|
2069
|
-
method.args.push({
|
|
2060
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
2070
2061
|
idx: this.propertyIndex,
|
|
2071
2062
|
type: "request"
|
|
2072
2063
|
});
|
|
@@ -2104,8 +2095,7 @@ var ResponseDecorator = class extends BaseDecorator {
|
|
|
2104
2095
|
*/
|
|
2105
2096
|
created() {
|
|
2106
2097
|
initializeMetadata(this.prototype);
|
|
2107
|
-
|
|
2108
|
-
method.args.push({
|
|
2098
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
2109
2099
|
idx: this.propertyIndex,
|
|
2110
2100
|
type: "response"
|
|
2111
2101
|
});
|
|
@@ -2125,7 +2115,6 @@ function Response$1() {
|
|
|
2125
2115
|
|
|
2126
2116
|
//#endregion
|
|
2127
2117
|
//#region src/Decorators/Http/Trace.ts
|
|
2128
|
-
var import_decorate$2 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
2129
2118
|
/**
|
|
2130
2119
|
* A decorator class for handling HTTP TRACE requests.
|
|
2131
2120
|
*
|
|
@@ -2164,9 +2153,9 @@ var TraceDecorator = class extends BaseDecorator {
|
|
|
2164
2153
|
});
|
|
2165
2154
|
}
|
|
2166
2155
|
};
|
|
2167
|
-
(
|
|
2168
|
-
(
|
|
2169
|
-
(
|
|
2156
|
+
__decorate([Inject(Router)], TraceDecorator.prototype, "gRouter", void 0);
|
|
2157
|
+
__decorate([Inject(RequestHandler)], TraceDecorator.prototype, "gRequestHandler", void 0);
|
|
2158
|
+
__decorate([Inject(MetadataResolver)], TraceDecorator.prototype, "gMetadataResolver", void 0);
|
|
2170
2159
|
/**
|
|
2171
2160
|
* A factory function for creating a TraceDecorator.
|
|
2172
2161
|
*
|
|
@@ -2194,8 +2183,7 @@ var SetHeaderDecorator = class extends BaseDecorator {
|
|
|
2194
2183
|
*/
|
|
2195
2184
|
created() {
|
|
2196
2185
|
initializeMetadata(this.prototype);
|
|
2197
|
-
|
|
2198
|
-
method.actions.push({ handler: (req, res) => {
|
|
2186
|
+
initializeMetadataMethod(this.prototype, this.propertyName).actions.push({ handler: (req, res) => {
|
|
2199
2187
|
res.headers.delete(this.options.key);
|
|
2200
2188
|
res.headers.append(this.options.key, this.options.value);
|
|
2201
2189
|
return res;
|
|
@@ -2215,39 +2203,94 @@ function SetHeader(key, value) {
|
|
|
2215
2203
|
});
|
|
2216
2204
|
}
|
|
2217
2205
|
|
|
2206
|
+
//#endregion
|
|
2207
|
+
//#region src/Types/HttpTypes.ts
|
|
2208
|
+
let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
2209
|
+
HTTPStatus$1[HTTPStatus$1["CONTINUE"] = 100] = "CONTINUE";
|
|
2210
|
+
HTTPStatus$1[HTTPStatus$1["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
2211
|
+
HTTPStatus$1[HTTPStatus$1["PROCESSING"] = 102] = "PROCESSING";
|
|
2212
|
+
HTTPStatus$1[HTTPStatus$1["OK"] = 200] = "OK";
|
|
2213
|
+
HTTPStatus$1[HTTPStatus$1["CREATED"] = 201] = "CREATED";
|
|
2214
|
+
HTTPStatus$1[HTTPStatus$1["ACCEPTED"] = 202] = "ACCEPTED";
|
|
2215
|
+
HTTPStatus$1[HTTPStatus$1["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
2216
|
+
HTTPStatus$1[HTTPStatus$1["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
2217
|
+
HTTPStatus$1[HTTPStatus$1["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
2218
|
+
HTTPStatus$1[HTTPStatus$1["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
2219
|
+
HTTPStatus$1[HTTPStatus$1["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
2220
|
+
HTTPStatus$1[HTTPStatus$1["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
2221
|
+
HTTPStatus$1[HTTPStatus$1["IM_USED"] = 226] = "IM_USED";
|
|
2222
|
+
HTTPStatus$1[HTTPStatus$1["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
2223
|
+
HTTPStatus$1[HTTPStatus$1["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
2224
|
+
HTTPStatus$1[HTTPStatus$1["FOUND"] = 302] = "FOUND";
|
|
2225
|
+
HTTPStatus$1[HTTPStatus$1["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
2226
|
+
HTTPStatus$1[HTTPStatus$1["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
2227
|
+
HTTPStatus$1[HTTPStatus$1["USE_PROXY"] = 305] = "USE_PROXY";
|
|
2228
|
+
HTTPStatus$1[HTTPStatus$1["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
2229
|
+
HTTPStatus$1[HTTPStatus$1["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
2230
|
+
HTTPStatus$1[HTTPStatus$1["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
2231
|
+
HTTPStatus$1[HTTPStatus$1["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
2232
|
+
HTTPStatus$1[HTTPStatus$1["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
2233
|
+
HTTPStatus$1[HTTPStatus$1["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
2234
|
+
HTTPStatus$1[HTTPStatus$1["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
2235
|
+
HTTPStatus$1[HTTPStatus$1["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
2236
|
+
HTTPStatus$1[HTTPStatus$1["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
2237
|
+
HTTPStatus$1[HTTPStatus$1["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
2238
|
+
HTTPStatus$1[HTTPStatus$1["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
2239
|
+
HTTPStatus$1[HTTPStatus$1["CONFLICT"] = 409] = "CONFLICT";
|
|
2240
|
+
HTTPStatus$1[HTTPStatus$1["GONE"] = 410] = "GONE";
|
|
2241
|
+
HTTPStatus$1[HTTPStatus$1["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
2242
|
+
HTTPStatus$1[HTTPStatus$1["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
2243
|
+
HTTPStatus$1[HTTPStatus$1["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
2244
|
+
HTTPStatus$1[HTTPStatus$1["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
2245
|
+
HTTPStatus$1[HTTPStatus$1["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
2246
|
+
HTTPStatus$1[HTTPStatus$1["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
2247
|
+
HTTPStatus$1[HTTPStatus$1["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
2248
|
+
HTTPStatus$1[HTTPStatus$1["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
2249
|
+
HTTPStatus$1[HTTPStatus$1["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
2250
|
+
HTTPStatus$1[HTTPStatus$1["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
2251
|
+
HTTPStatus$1[HTTPStatus$1["LOCKED"] = 423] = "LOCKED";
|
|
2252
|
+
HTTPStatus$1[HTTPStatus$1["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
2253
|
+
HTTPStatus$1[HTTPStatus$1["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
2254
|
+
HTTPStatus$1[HTTPStatus$1["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
2255
|
+
HTTPStatus$1[HTTPStatus$1["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
2256
|
+
HTTPStatus$1[HTTPStatus$1["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
2257
|
+
HTTPStatus$1[HTTPStatus$1["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
2258
|
+
HTTPStatus$1[HTTPStatus$1["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
2259
|
+
HTTPStatus$1[HTTPStatus$1["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
2260
|
+
HTTPStatus$1[HTTPStatus$1["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
2261
|
+
HTTPStatus$1[HTTPStatus$1["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
2262
|
+
HTTPStatus$1[HTTPStatus$1["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
2263
|
+
HTTPStatus$1[HTTPStatus$1["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
2264
|
+
HTTPStatus$1[HTTPStatus$1["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
2265
|
+
HTTPStatus$1[HTTPStatus$1["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
2266
|
+
HTTPStatus$1[HTTPStatus$1["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
2267
|
+
HTTPStatus$1[HTTPStatus$1["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
2268
|
+
HTTPStatus$1[HTTPStatus$1["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
2269
|
+
HTTPStatus$1[HTTPStatus$1["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
2270
|
+
return HTTPStatus$1;
|
|
2271
|
+
}({});
|
|
2272
|
+
|
|
2218
2273
|
//#endregion
|
|
2219
2274
|
//#region src/Decorators/Http/Status.ts
|
|
2220
2275
|
/**
|
|
2221
|
-
|
|
2222
2276
|
* A decorator that sets a status on the response.
|
|
2223
|
-
|
|
2224
2277
|
* @extends {BaseDecorator<StatusDecoratorOptions>}
|
|
2225
|
-
|
|
2226
2278
|
*/
|
|
2227
2279
|
var StatusDecorator = class extends BaseDecorator {
|
|
2228
2280
|
/**
|
|
2229
|
-
|
|
2230
2281
|
* Called when the decorator is created.
|
|
2231
|
-
|
|
2232
2282
|
* Sets a status on the response
|
|
2233
|
-
|
|
2234
2283
|
* @override
|
|
2235
|
-
|
|
2236
2284
|
*/
|
|
2237
2285
|
created() {
|
|
2238
2286
|
initializeMetadata(this.prototype);
|
|
2239
|
-
|
|
2240
|
-
method.actions.push({ handler: () => ({ status: this.options.code }) });
|
|
2287
|
+
initializeMetadataMethod(this.prototype, this.propertyName).actions.push({ handler: () => ({ status: this.options.code }) });
|
|
2241
2288
|
}
|
|
2242
2289
|
};
|
|
2243
2290
|
/**
|
|
2244
|
-
|
|
2245
2291
|
* Creates a Status decorator.
|
|
2246
|
-
|
|
2247
2292
|
* @param {number} code - The status value.
|
|
2248
|
-
|
|
2249
2293
|
* @returns {Function} The decorator function.
|
|
2250
|
-
|
|
2251
2294
|
*/
|
|
2252
2295
|
function Status(code) {
|
|
2253
2296
|
return createDecorator(StatusDecorator, { code });
|
|
@@ -2257,37 +2300,26 @@ function Status(code) {
|
|
|
2257
2300
|
//#region src/Decorators/Http/Redirect.ts
|
|
2258
2301
|
var RedirectDecorator = class extends BaseDecorator {
|
|
2259
2302
|
/**
|
|
2260
|
-
|
|
2261
2303
|
* Decorator responsible for redirecting to a specified URL.
|
|
2262
|
-
|
|
2263
2304
|
* Called when the decorator is created.
|
|
2264
|
-
|
|
2265
2305
|
* Sets the location header value and status code.
|
|
2266
|
-
|
|
2267
2306
|
* @override
|
|
2268
|
-
|
|
2269
2307
|
*/
|
|
2270
2308
|
created() {
|
|
2271
2309
|
initializeMetadata(this.prototype);
|
|
2272
|
-
|
|
2273
|
-
method.actions.push({ handler: () => {
|
|
2310
|
+
initializeMetadataMethod(this.prototype, this.propertyName).actions.push({ handler: () => {
|
|
2274
2311
|
return new FastResponse(void 0, {
|
|
2275
2312
|
status: this.options.code,
|
|
2276
|
-
headers: {
|
|
2313
|
+
headers: { Location: this.options.location }
|
|
2277
2314
|
});
|
|
2278
2315
|
} });
|
|
2279
2316
|
}
|
|
2280
2317
|
};
|
|
2281
2318
|
/**
|
|
2282
|
-
|
|
2283
2319
|
* Creates a Redirect decorator.
|
|
2284
|
-
|
|
2285
2320
|
* @param {string} location - The location header value.
|
|
2286
|
-
|
|
2287
2321
|
* @param {number} [code=301] - The status code.
|
|
2288
|
-
|
|
2289
2322
|
* @returns {Function} The decorator function.
|
|
2290
|
-
|
|
2291
2323
|
*/
|
|
2292
2324
|
function Redirect(location, code = 301) {
|
|
2293
2325
|
return createDecorator(RedirectDecorator, {
|
|
@@ -2323,8 +2355,7 @@ function Redirect(location, code = 301) {
|
|
|
2323
2355
|
function Middleware(middleware, opts) {
|
|
2324
2356
|
return function internalDecorator(target, propertyName) {
|
|
2325
2357
|
const ctx = propertyName ? target : target.prototype;
|
|
2326
|
-
|
|
2327
|
-
meta.__middlewares.push({
|
|
2358
|
+
initializeMetadata(ctx).__middlewares.push({
|
|
2328
2359
|
target: propertyName ?? "__global__",
|
|
2329
2360
|
priority: opts?.priority ?? 999,
|
|
2330
2361
|
middleware
|
|
@@ -2348,8 +2379,7 @@ var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
|
2348
2379
|
*/
|
|
2349
2380
|
created() {
|
|
2350
2381
|
initializeMetadata(this.prototype);
|
|
2351
|
-
|
|
2352
|
-
method.args.push({
|
|
2382
|
+
initializeMetadataMethod(this.prototype, this.propertyName).args.push({
|
|
2353
2383
|
idx: this.propertyIndex,
|
|
2354
2384
|
type: "multipart-form-data"
|
|
2355
2385
|
});
|
|
@@ -2358,10 +2388,10 @@ var MultipartFormDataDecorator = class extends BaseDecorator {
|
|
|
2358
2388
|
/**
|
|
2359
2389
|
* Decorator function that marks a parameter as multipart/form-data request body.
|
|
2360
2390
|
* This decorator will automatically parse incoming multipart form data
|
|
2361
|
-
*
|
|
2391
|
+
*
|
|
2362
2392
|
* @decorator
|
|
2363
2393
|
* @returns {Function} A decorator function that can be applied to method parameters
|
|
2364
|
-
*
|
|
2394
|
+
*
|
|
2365
2395
|
* @example
|
|
2366
2396
|
* class UserController {
|
|
2367
2397
|
* uploadFile(@MultipartFormData() formData: MyData) {
|
|
@@ -2373,56 +2403,8 @@ function MultipartFormData() {
|
|
|
2373
2403
|
return createDecorator(MultipartFormDataDecorator, {});
|
|
2374
2404
|
}
|
|
2375
2405
|
|
|
2376
|
-
//#endregion
|
|
2377
|
-
//#region src/Decorators/Http/Session.ts
|
|
2378
|
-
var import_decorate$1 = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
2379
|
-
/**
|
|
2380
|
-
* This class is responsible for managing session decorators.
|
|
2381
|
-
*
|
|
2382
|
-
* This class extends the BaseDecorator and is used to register session information
|
|
2383
|
-
* with the MetadataResolver. It ensures that the metadata for the property is created
|
|
2384
|
-
* and adds the session information to the metadata.
|
|
2385
|
-
*
|
|
2386
|
-
* @extends {BaseDecorator<{}>}
|
|
2387
|
-
*/
|
|
2388
|
-
var SessionDecorator = class extends BaseDecorator {
|
|
2389
|
-
gRuntimeConfig;
|
|
2390
|
-
/**
|
|
2391
|
-
* Called when the decorator is created.
|
|
2392
|
-
*
|
|
2393
|
-
* This method checks if metadata for the property exists, creates it if it doesn't,
|
|
2394
|
-
* and then adds the session information to the metadata.
|
|
2395
|
-
*/
|
|
2396
|
-
created() {
|
|
2397
|
-
initializeMetadata(this.prototype);
|
|
2398
|
-
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
2399
|
-
method.args.push({
|
|
2400
|
-
idx: this.propertyIndex,
|
|
2401
|
-
type: "session",
|
|
2402
|
-
data: {
|
|
2403
|
-
name: this.gRuntimeConfig.runtimeConfig.session?.name ?? "vercube_session",
|
|
2404
|
-
secret: this.gRuntimeConfig.runtimeConfig.session?.secret ?? generateRandomHash(),
|
|
2405
|
-
duration: this.gRuntimeConfig.runtimeConfig.session?.duration ?? 3600 * 24 * 7
|
|
2406
|
-
}
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2409
|
-
};
|
|
2410
|
-
(0, import_decorate$1.default)([Inject(RuntimeConfig)], SessionDecorator.prototype, "gRuntimeConfig", void 0);
|
|
2411
|
-
/**
|
|
2412
|
-
* A factory function for creating a SessionDecorator.
|
|
2413
|
-
*
|
|
2414
|
-
* This function returns a decorator function that can be used to annotate
|
|
2415
|
-
* a method parameter with session information.
|
|
2416
|
-
*
|
|
2417
|
-
* @return {Function} The decorator function.
|
|
2418
|
-
*/
|
|
2419
|
-
function Session() {
|
|
2420
|
-
return createDecorator(SessionDecorator, {});
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
2406
|
//#endregion
|
|
2424
2407
|
//#region src/Decorators/Hooks/Listen.ts
|
|
2425
|
-
var import_decorate = /* @__PURE__ */ __toESM(require_decorate(), 1);
|
|
2426
2408
|
/**
|
|
2427
2409
|
* This class is responsible for managing cache decorator.
|
|
2428
2410
|
*/
|
|
@@ -2443,7 +2425,7 @@ var ListenDecorator = class extends BaseDecorator {
|
|
|
2443
2425
|
this.gHooksService.off(this.fHook);
|
|
2444
2426
|
}
|
|
2445
2427
|
};
|
|
2446
|
-
(
|
|
2428
|
+
__decorate([Inject(HooksService)], ListenDecorator.prototype, "gHooksService", void 0);
|
|
2447
2429
|
/**
|
|
2448
2430
|
* This decorator stores metadata about hook listeners. It can be later used along with function
|
|
2449
2431
|
* applyEventListeners() to automatically register all listeners.
|
|
@@ -2455,31 +2437,6 @@ function Listen(hookType) {
|
|
|
2455
2437
|
return createDecorator(ListenDecorator, { hookType });
|
|
2456
2438
|
}
|
|
2457
2439
|
|
|
2458
|
-
//#endregion
|
|
2459
|
-
//#region src/Services/Plugins/BasePlugin.ts
|
|
2460
|
-
/**
|
|
2461
|
-
* Represents a Plugin.
|
|
2462
|
-
*/
|
|
2463
|
-
var BasePlugin = class {
|
|
2464
|
-
/**
|
|
2465
|
-
* The name of the plugin.
|
|
2466
|
-
*/
|
|
2467
|
-
name;
|
|
2468
|
-
/**
|
|
2469
|
-
* Uses the plugin with the given app.
|
|
2470
|
-
* @param {App} app - The application instance.
|
|
2471
|
-
* @returns {void | Promise<void>} - A void or a promise that resolves to void.
|
|
2472
|
-
*/
|
|
2473
|
-
use(app, options) {}
|
|
2474
|
-
};
|
|
2475
|
-
|
|
2476
|
-
//#endregion
|
|
2477
|
-
//#region src/Services/Middleware/BaseMiddleware.ts
|
|
2478
|
-
/**
|
|
2479
|
-
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
2480
|
-
*/
|
|
2481
|
-
var BaseMiddleware = class {};
|
|
2482
|
-
|
|
2483
2440
|
//#endregion
|
|
2484
2441
|
//#region src/Errors/Http/ForbiddenError.ts
|
|
2485
2442
|
/**
|
|
@@ -2549,29 +2506,6 @@ var NotAcceptableError = class NotAcceptableError extends HttpError {
|
|
|
2549
2506
|
}
|
|
2550
2507
|
};
|
|
2551
2508
|
|
|
2552
|
-
//#endregion
|
|
2553
|
-
//#region src/Errors/Http/NotFoundError.ts
|
|
2554
|
-
/**
|
|
2555
|
-
* Represents a Not Found error (HTTP 404).
|
|
2556
|
-
* @extends {HttpError}
|
|
2557
|
-
*/
|
|
2558
|
-
var NotFoundError = class NotFoundError extends HttpError {
|
|
2559
|
-
/**
|
|
2560
|
-
* The name of the error.
|
|
2561
|
-
* @type {string}
|
|
2562
|
-
*/
|
|
2563
|
-
name = "NotFoundError";
|
|
2564
|
-
/**
|
|
2565
|
-
* Creates an instance of NotFoundError.
|
|
2566
|
-
* @param {string} [message] - The error message.
|
|
2567
|
-
*/
|
|
2568
|
-
constructor(message) {
|
|
2569
|
-
super(404);
|
|
2570
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
2571
|
-
if (message) this.message = message;
|
|
2572
|
-
}
|
|
2573
|
-
};
|
|
2574
|
-
|
|
2575
2509
|
//#endregion
|
|
2576
2510
|
//#region src/Errors/Http/UnauthorizedError.ts
|
|
2577
2511
|
/**
|
|
@@ -2595,73 +2529,6 @@ var UnauthorizedError = class UnauthorizedError extends HttpError {
|
|
|
2595
2529
|
}
|
|
2596
2530
|
};
|
|
2597
2531
|
|
|
2598
|
-
//#endregion
|
|
2599
|
-
//#region src/Types/HttpTypes.ts
|
|
2600
|
-
let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
2601
|
-
HTTPStatus$1[HTTPStatus$1["CONTINUE"] = 100] = "CONTINUE";
|
|
2602
|
-
HTTPStatus$1[HTTPStatus$1["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
2603
|
-
HTTPStatus$1[HTTPStatus$1["PROCESSING"] = 102] = "PROCESSING";
|
|
2604
|
-
HTTPStatus$1[HTTPStatus$1["OK"] = 200] = "OK";
|
|
2605
|
-
HTTPStatus$1[HTTPStatus$1["CREATED"] = 201] = "CREATED";
|
|
2606
|
-
HTTPStatus$1[HTTPStatus$1["ACCEPTED"] = 202] = "ACCEPTED";
|
|
2607
|
-
HTTPStatus$1[HTTPStatus$1["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
2608
|
-
HTTPStatus$1[HTTPStatus$1["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
2609
|
-
HTTPStatus$1[HTTPStatus$1["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
2610
|
-
HTTPStatus$1[HTTPStatus$1["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
2611
|
-
HTTPStatus$1[HTTPStatus$1["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
2612
|
-
HTTPStatus$1[HTTPStatus$1["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
2613
|
-
HTTPStatus$1[HTTPStatus$1["IM_USED"] = 226] = "IM_USED";
|
|
2614
|
-
HTTPStatus$1[HTTPStatus$1["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
2615
|
-
HTTPStatus$1[HTTPStatus$1["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
2616
|
-
HTTPStatus$1[HTTPStatus$1["FOUND"] = 302] = "FOUND";
|
|
2617
|
-
HTTPStatus$1[HTTPStatus$1["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
2618
|
-
HTTPStatus$1[HTTPStatus$1["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
2619
|
-
HTTPStatus$1[HTTPStatus$1["USE_PROXY"] = 305] = "USE_PROXY";
|
|
2620
|
-
HTTPStatus$1[HTTPStatus$1["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
2621
|
-
HTTPStatus$1[HTTPStatus$1["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
2622
|
-
HTTPStatus$1[HTTPStatus$1["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
2623
|
-
HTTPStatus$1[HTTPStatus$1["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
2624
|
-
HTTPStatus$1[HTTPStatus$1["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
2625
|
-
HTTPStatus$1[HTTPStatus$1["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
2626
|
-
HTTPStatus$1[HTTPStatus$1["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
2627
|
-
HTTPStatus$1[HTTPStatus$1["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
2628
|
-
HTTPStatus$1[HTTPStatus$1["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
2629
|
-
HTTPStatus$1[HTTPStatus$1["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
2630
|
-
HTTPStatus$1[HTTPStatus$1["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
2631
|
-
HTTPStatus$1[HTTPStatus$1["CONFLICT"] = 409] = "CONFLICT";
|
|
2632
|
-
HTTPStatus$1[HTTPStatus$1["GONE"] = 410] = "GONE";
|
|
2633
|
-
HTTPStatus$1[HTTPStatus$1["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
2634
|
-
HTTPStatus$1[HTTPStatus$1["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
2635
|
-
HTTPStatus$1[HTTPStatus$1["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
2636
|
-
HTTPStatus$1[HTTPStatus$1["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
2637
|
-
HTTPStatus$1[HTTPStatus$1["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
2638
|
-
HTTPStatus$1[HTTPStatus$1["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
2639
|
-
HTTPStatus$1[HTTPStatus$1["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
2640
|
-
HTTPStatus$1[HTTPStatus$1["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
2641
|
-
HTTPStatus$1[HTTPStatus$1["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
2642
|
-
HTTPStatus$1[HTTPStatus$1["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
2643
|
-
HTTPStatus$1[HTTPStatus$1["LOCKED"] = 423] = "LOCKED";
|
|
2644
|
-
HTTPStatus$1[HTTPStatus$1["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
2645
|
-
HTTPStatus$1[HTTPStatus$1["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
2646
|
-
HTTPStatus$1[HTTPStatus$1["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
2647
|
-
HTTPStatus$1[HTTPStatus$1["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
2648
|
-
HTTPStatus$1[HTTPStatus$1["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
2649
|
-
HTTPStatus$1[HTTPStatus$1["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
2650
|
-
HTTPStatus$1[HTTPStatus$1["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
2651
|
-
HTTPStatus$1[HTTPStatus$1["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
2652
|
-
HTTPStatus$1[HTTPStatus$1["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
2653
|
-
HTTPStatus$1[HTTPStatus$1["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
2654
|
-
HTTPStatus$1[HTTPStatus$1["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
2655
|
-
HTTPStatus$1[HTTPStatus$1["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
2656
|
-
HTTPStatus$1[HTTPStatus$1["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
2657
|
-
HTTPStatus$1[HTTPStatus$1["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
2658
|
-
HTTPStatus$1[HTTPStatus$1["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
2659
|
-
HTTPStatus$1[HTTPStatus$1["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
2660
|
-
HTTPStatus$1[HTTPStatus$1["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
2661
|
-
HTTPStatus$1[HTTPStatus$1["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
2662
|
-
return HTTPStatus$1;
|
|
2663
|
-
}({});
|
|
2664
|
-
|
|
2665
2532
|
//#endregion
|
|
2666
2533
|
//#region src/Types/HttpCodes.ts
|
|
2667
2534
|
/**
|
|
@@ -2993,4 +2860,4 @@ let HttpStatusCode = /* @__PURE__ */ function(HttpStatusCode$1) {
|
|
|
2993
2860
|
}({});
|
|
2994
2861
|
|
|
2995
2862
|
//#endregion
|
|
2996
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Router, RuntimeConfig,
|
|
2863
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Router, RuntimeConfig, SetHeader, StandardSchemaValidationProvider, Status, Trace, UnauthorizedError, ValidationProvider, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|