@vercube/core 0.0.18 → 0.0.20
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/dist/index.d.mts +524 -138
- package/dist/index.mjs +382 -20
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Container } from "@vercube/di";
|
|
2
|
-
import { FastResponse } from "srvx";
|
|
2
|
+
import { FastResponse, ServerPlugin } from "srvx";
|
|
3
3
|
import { LoggerTypes } from "@vercube/logger";
|
|
4
4
|
import { DotenvOptions } from "c12";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -218,12 +218,12 @@ declare class App {
|
|
|
218
218
|
*/
|
|
219
219
|
init(cfg: ConfigTypes.Config): Promise<void>;
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
221
|
+
* Add new plugin to the application.
|
|
222
222
|
*
|
|
223
|
-
* @param {typeof Plugin} plugin - The plugin to
|
|
223
|
+
* @param {typeof Plugin} plugin - The plugin to add.
|
|
224
224
|
* @param {unknown} options - The options to pass to the plugin.
|
|
225
225
|
*/
|
|
226
|
-
|
|
226
|
+
addPlugin<T>(plugin: typeof BasePlugin<T>, options?: T): void;
|
|
227
227
|
/**
|
|
228
228
|
* Starts the application and begins listening for incoming requests.
|
|
229
229
|
*
|
|
@@ -247,13 +247,156 @@ declare class App {
|
|
|
247
247
|
private resolvePlugins;
|
|
248
248
|
}
|
|
249
249
|
//#endregion
|
|
250
|
+
//#region src/Services/Middleware/BaseMiddleware.d.ts
|
|
251
|
+
/**
|
|
252
|
+
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
253
|
+
*/
|
|
254
|
+
declare class BaseMiddleware<T = any, U = any> {
|
|
255
|
+
/**
|
|
256
|
+
* Middleware function that processes the HTTP event.
|
|
257
|
+
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
258
|
+
* WARNING: This method cannot return a value, it will be ignored.
|
|
259
|
+
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
260
|
+
*
|
|
261
|
+
* @param {Request} request - The HTTP Request to process
|
|
262
|
+
* @param {T[]} args - Additional arguments for the middleware.
|
|
263
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
264
|
+
*/
|
|
265
|
+
onRequest?(request: Request, response: Response, args: MiddlewareOptions<T>): MaybePromise<void | Response>;
|
|
266
|
+
/**
|
|
267
|
+
* Middleware function that processes the response.
|
|
268
|
+
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
269
|
+
* WARNING: This method cannot return a value, it will be ignored.
|
|
270
|
+
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
271
|
+
*
|
|
272
|
+
* @param {Request} request - The HTTP Request to process
|
|
273
|
+
* @param {Response} response - The HTTP Response to process
|
|
274
|
+
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
275
|
+
*/
|
|
276
|
+
onResponse?(request: Request, response: Response, payload: U): MaybePromise<void | Response>;
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/Types/RouterTypes.d.ts
|
|
280
|
+
declare namespace RouterTypes {
|
|
281
|
+
interface Route {
|
|
282
|
+
path: string;
|
|
283
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
|
|
284
|
+
handler: RouterHandler;
|
|
285
|
+
}
|
|
286
|
+
interface RouteFind {
|
|
287
|
+
path: string;
|
|
288
|
+
method: string;
|
|
289
|
+
}
|
|
290
|
+
interface MiddlewareDefinition {
|
|
291
|
+
middleware: BaseMiddleware<unknown, unknown>;
|
|
292
|
+
target: string;
|
|
293
|
+
priority?: number;
|
|
294
|
+
args?: unknown;
|
|
295
|
+
}
|
|
296
|
+
interface RouterHandler {
|
|
297
|
+
instance: any;
|
|
298
|
+
propertyName: string;
|
|
299
|
+
args: MetadataTypes.Arg[];
|
|
300
|
+
middlewares: {
|
|
301
|
+
beforeMiddlewares: MiddlewareDefinition[];
|
|
302
|
+
afterMiddlewares: MiddlewareDefinition[];
|
|
303
|
+
};
|
|
304
|
+
actions: MetadataTypes.Action[];
|
|
305
|
+
}
|
|
306
|
+
interface RouteMatched<T = unknown> {
|
|
307
|
+
data: T;
|
|
308
|
+
params?: Record<string, string>;
|
|
309
|
+
}
|
|
310
|
+
type RouterEvent = RouterTypes.RouteMatched<RouterTypes.RouterHandler> & {
|
|
311
|
+
request: Request;
|
|
312
|
+
response: Response;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/Types/ValidationTypes.d.ts
|
|
317
|
+
declare namespace ValidationTypes {
|
|
318
|
+
type Schema = StandardSchemaV1;
|
|
319
|
+
type Result<T = any> = StandardSchemaV1.Result<T>;
|
|
320
|
+
type Input<T extends Schema = Schema> = StandardSchemaV1.InferInput<T>;
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/Types/MetadataTypes.d.ts
|
|
324
|
+
declare namespace MetadataTypes {
|
|
325
|
+
interface Metadata {
|
|
326
|
+
__metadata: Ctx;
|
|
327
|
+
}
|
|
328
|
+
interface Ctx {
|
|
329
|
+
__controller: {
|
|
330
|
+
path: string;
|
|
331
|
+
};
|
|
332
|
+
__middlewares: Middleware[];
|
|
333
|
+
__methods: Record<string, Method>;
|
|
334
|
+
__meta?: Record<string, unknown>;
|
|
335
|
+
}
|
|
336
|
+
interface Method {
|
|
337
|
+
req: Request | null;
|
|
338
|
+
res: Response | null;
|
|
339
|
+
url: string | null;
|
|
340
|
+
method: string | null;
|
|
341
|
+
args: Arg[];
|
|
342
|
+
actions: Action[];
|
|
343
|
+
meta: Record<string, unknown>;
|
|
344
|
+
}
|
|
345
|
+
interface ResolvedData {
|
|
346
|
+
req: Request | null;
|
|
347
|
+
res: Response | null;
|
|
348
|
+
url: string | null;
|
|
349
|
+
args: Arg[];
|
|
350
|
+
actions: Action[];
|
|
351
|
+
middlewares: Middleware[];
|
|
352
|
+
}
|
|
353
|
+
interface Arg {
|
|
354
|
+
idx: number;
|
|
355
|
+
type: string;
|
|
356
|
+
data?: Record<string, any>;
|
|
357
|
+
resolver?: (event: RouterTypes.RouterEvent) => Promise<unknown>;
|
|
358
|
+
resolved?: unknown;
|
|
359
|
+
validate?: boolean;
|
|
360
|
+
validationSchema?: ValidationTypes.Schema;
|
|
361
|
+
}
|
|
362
|
+
interface Action {
|
|
363
|
+
handler: (req: Request, res: Response) => void | Response | ResponseInit;
|
|
364
|
+
}
|
|
365
|
+
interface Middleware<T = unknown, U = unknown> {
|
|
366
|
+
target: string;
|
|
367
|
+
priority?: number;
|
|
368
|
+
middleware: typeof BaseMiddleware<T, U>;
|
|
369
|
+
args?: unknown;
|
|
370
|
+
}
|
|
371
|
+
interface ResolveUrlParams {
|
|
372
|
+
instance: any;
|
|
373
|
+
path: string;
|
|
374
|
+
propertyName: string;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/Types/CommonTypes.d.ts
|
|
379
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
380
|
+
interface MiddlewareOptions<T = any> {
|
|
381
|
+
middlewareArgs?: T;
|
|
382
|
+
methodArgs?: MetadataTypes.Arg[];
|
|
383
|
+
}
|
|
384
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
385
|
+
//#endregion
|
|
250
386
|
//#region src/Common/CreateApp.d.ts
|
|
387
|
+
interface CreateAppOptions {
|
|
388
|
+
cfg?: ConfigTypes.Config;
|
|
389
|
+
setup?: (app: App) => MaybePromise<void>;
|
|
390
|
+
}
|
|
251
391
|
/**
|
|
252
392
|
* Creates and initializes an instance of the App.
|
|
253
393
|
*
|
|
254
394
|
* @returns {Promise<App>} A promise that resolves to an instance of the App.
|
|
255
395
|
*/
|
|
256
|
-
declare function createApp(
|
|
396
|
+
declare function createApp({
|
|
397
|
+
cfg,
|
|
398
|
+
setup
|
|
399
|
+
}?: CreateAppOptions): Promise<App>;
|
|
257
400
|
//#endregion
|
|
258
401
|
//#region src/Config/Config.d.ts
|
|
259
402
|
/**
|
|
@@ -271,13 +414,6 @@ declare function defineConfig<T = Record<string, unknown>>(config: ConfigTypes.C
|
|
|
271
414
|
*/
|
|
272
415
|
declare function loadVercubeConfig(overrides?: ConfigTypes.Config): Promise<ConfigTypes.Config>;
|
|
273
416
|
//#endregion
|
|
274
|
-
//#region src/Types/ValidationTypes.d.ts
|
|
275
|
-
declare namespace ValidationTypes {
|
|
276
|
-
type Schema = StandardSchemaV1;
|
|
277
|
-
type Result<T = any> = StandardSchemaV1.Result<T>;
|
|
278
|
-
type Input<T extends Schema = Schema> = StandardSchemaV1.InferInput<T>;
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
417
|
//#region src/Decorators/Http/Body.d.ts
|
|
282
418
|
interface BodyDecoratorOptions {
|
|
283
419
|
validationSchema?: ValidationTypes.Schema;
|
|
@@ -596,131 +732,6 @@ declare function Status(code: HTTPStatus): Function;
|
|
|
596
732
|
*/
|
|
597
733
|
declare function Redirect(location: string, code?: HTTPStatus): Function;
|
|
598
734
|
//#endregion
|
|
599
|
-
//#region src/Types/RouterTypes.d.ts
|
|
600
|
-
declare namespace RouterTypes {
|
|
601
|
-
interface Route {
|
|
602
|
-
path: string;
|
|
603
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
|
|
604
|
-
handler: RouterHandler;
|
|
605
|
-
}
|
|
606
|
-
interface RouteFind {
|
|
607
|
-
path: string;
|
|
608
|
-
method: string;
|
|
609
|
-
}
|
|
610
|
-
interface MiddlewareDefinition {
|
|
611
|
-
middleware: BaseMiddleware<unknown, unknown>;
|
|
612
|
-
target: string;
|
|
613
|
-
priority?: number;
|
|
614
|
-
args?: unknown;
|
|
615
|
-
}
|
|
616
|
-
interface RouterHandler {
|
|
617
|
-
instance: any;
|
|
618
|
-
propertyName: string;
|
|
619
|
-
args: MetadataTypes.Arg[];
|
|
620
|
-
middlewares: {
|
|
621
|
-
beforeMiddlewares: MiddlewareDefinition[];
|
|
622
|
-
afterMiddlewares: MiddlewareDefinition[];
|
|
623
|
-
};
|
|
624
|
-
actions: MetadataTypes.Action[];
|
|
625
|
-
}
|
|
626
|
-
interface RouteMatched<T = unknown> {
|
|
627
|
-
data: T;
|
|
628
|
-
params?: Record<string, string>;
|
|
629
|
-
}
|
|
630
|
-
type RouterEvent = RouterTypes.RouteMatched<RouterTypes.RouterHandler> & {
|
|
631
|
-
request: Request;
|
|
632
|
-
response: Response;
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
//#endregion
|
|
636
|
-
//#region src/Types/MetadataTypes.d.ts
|
|
637
|
-
declare namespace MetadataTypes {
|
|
638
|
-
interface Metadata {
|
|
639
|
-
__metadata: Ctx;
|
|
640
|
-
}
|
|
641
|
-
interface Ctx {
|
|
642
|
-
__controller: {
|
|
643
|
-
path: string;
|
|
644
|
-
};
|
|
645
|
-
__middlewares: Middleware[];
|
|
646
|
-
__methods: Record<string, Method>;
|
|
647
|
-
}
|
|
648
|
-
interface Method {
|
|
649
|
-
req: Request | null;
|
|
650
|
-
res: Response | null;
|
|
651
|
-
url: string | null;
|
|
652
|
-
args: Arg[];
|
|
653
|
-
actions: Action[];
|
|
654
|
-
}
|
|
655
|
-
interface ResolvedData {
|
|
656
|
-
req: Request | null;
|
|
657
|
-
res: Response | null;
|
|
658
|
-
url: string | null;
|
|
659
|
-
args: Arg[];
|
|
660
|
-
actions: Action[];
|
|
661
|
-
middlewares: Middleware[];
|
|
662
|
-
}
|
|
663
|
-
interface Arg {
|
|
664
|
-
idx: number;
|
|
665
|
-
type: string;
|
|
666
|
-
data?: Record<string, any>;
|
|
667
|
-
resolver?: (event: RouterTypes.RouterEvent) => Promise<unknown>;
|
|
668
|
-
resolved?: unknown;
|
|
669
|
-
validate?: boolean;
|
|
670
|
-
validationSchema?: ValidationTypes.Schema;
|
|
671
|
-
}
|
|
672
|
-
interface Action {
|
|
673
|
-
handler: (req: Request, res: Response) => void | Response | ResponseInit;
|
|
674
|
-
}
|
|
675
|
-
interface Middleware<T = unknown, U = unknown> {
|
|
676
|
-
target: string;
|
|
677
|
-
priority?: number;
|
|
678
|
-
middleware: typeof BaseMiddleware<T, U>;
|
|
679
|
-
args?: unknown;
|
|
680
|
-
}
|
|
681
|
-
interface ResolveUrlParams {
|
|
682
|
-
instance: any;
|
|
683
|
-
path: string;
|
|
684
|
-
propertyName: string;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
//#endregion
|
|
688
|
-
//#region src/Types/CommonTypes.d.ts
|
|
689
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
690
|
-
interface MiddlewareOptions<T = any> {
|
|
691
|
-
middlewareArgs?: T;
|
|
692
|
-
methodArgs?: MetadataTypes.Arg[];
|
|
693
|
-
}
|
|
694
|
-
//#endregion
|
|
695
|
-
//#region src/Services/Middleware/BaseMiddleware.d.ts
|
|
696
|
-
/**
|
|
697
|
-
* BaseMiddleware class that serves as a base for all middleware implementations.
|
|
698
|
-
*/
|
|
699
|
-
declare class BaseMiddleware<T = any, U = any> {
|
|
700
|
-
/**
|
|
701
|
-
* Middleware function that processes the HTTP event.
|
|
702
|
-
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
703
|
-
* WARNING: This method cannot return a value, it will be ignored.
|
|
704
|
-
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
705
|
-
*
|
|
706
|
-
* @param {Request} request - The HTTP Request to process
|
|
707
|
-
* @param {T[]} args - Additional arguments for the middleware.
|
|
708
|
-
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
709
|
-
*/
|
|
710
|
-
onRequest?(request: Request, response: Response, args: MiddlewareOptions<T>): MaybePromise<void | Response>;
|
|
711
|
-
/**
|
|
712
|
-
* Middleware function that processes the response.
|
|
713
|
-
* This method should be overridden by subclasses to implement specific middleware logic.
|
|
714
|
-
* WARNING: This method cannot return a value, it will be ignored.
|
|
715
|
-
* Middleware can only modify the event object or throw an HttpError like BadRequestError, ForbiddenError, etc.
|
|
716
|
-
*
|
|
717
|
-
* @param {Request} request - The HTTP Request to process
|
|
718
|
-
* @param {Response} response - The HTTP Response to process
|
|
719
|
-
* @returns {void | Promise<void>} - A void or a promise that resolves when the processing is complete.
|
|
720
|
-
*/
|
|
721
|
-
onResponse?(request: Request, response: Response, payload: U): MaybePromise<void | Response>;
|
|
722
|
-
}
|
|
723
|
-
//#endregion
|
|
724
735
|
//#region src/Decorators/Http/Middleware.d.ts
|
|
725
736
|
interface MiddlewareDecoratorParams extends Omit<MetadataTypes.Middleware, 'middleware'> {}
|
|
726
737
|
/**
|
|
@@ -916,6 +927,18 @@ declare class HttpServer {
|
|
|
916
927
|
* @private
|
|
917
928
|
*/
|
|
918
929
|
private fServer;
|
|
930
|
+
/**
|
|
931
|
+
* List of plugins to be applied to the HTTP server
|
|
932
|
+
* @private
|
|
933
|
+
*/
|
|
934
|
+
private fPlugins;
|
|
935
|
+
/**
|
|
936
|
+
* Adds a plugin to the HTTP server
|
|
937
|
+
*
|
|
938
|
+
* @param {ServerPlugin} plugin - The plugin to add
|
|
939
|
+
* @returns {void}
|
|
940
|
+
*/
|
|
941
|
+
addPlugin(plugin: ServerPlugin): void;
|
|
919
942
|
/**
|
|
920
943
|
* Initializes the HTTP server and starts listening for requests
|
|
921
944
|
*
|
|
@@ -1067,6 +1090,41 @@ declare class RuntimeConfig$1<T = Record<string, unknown>> {
|
|
|
1067
1090
|
set runtimeConfig(value: ConfigTypes.CreateRuntimeConfig<T> | undefined);
|
|
1068
1091
|
}
|
|
1069
1092
|
//#endregion
|
|
1093
|
+
//#region src/Services/Validation/ValidationProvider.d.ts
|
|
1094
|
+
/**
|
|
1095
|
+
* Abstract class representing a validation provider
|
|
1096
|
+
* Provides a common interface for different validation implementations
|
|
1097
|
+
*
|
|
1098
|
+
* @abstract
|
|
1099
|
+
* @class ValidationProvider
|
|
1100
|
+
*/
|
|
1101
|
+
declare abstract class ValidationProvider {
|
|
1102
|
+
/**
|
|
1103
|
+
* Validates data against a given schema
|
|
1104
|
+
* @param schema - The validation schema to check against
|
|
1105
|
+
* @param data - The data to validate
|
|
1106
|
+
* @returns A validation result object or Promise of validation result
|
|
1107
|
+
*/
|
|
1108
|
+
abstract validate(schema: ValidationTypes.Schema, data: ValidationTypes.Input): ValidationTypes.Result | Promise<ValidationTypes.Result>;
|
|
1109
|
+
}
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region src/Services/Validation/StandardSchemaValidationProvider.d.ts
|
|
1112
|
+
/**
|
|
1113
|
+
* StandardSchemaValidationProvider implements validation using StandardSchema schema validation
|
|
1114
|
+
* @see https://github.com/standard-schema/standard-schema
|
|
1115
|
+
* @class
|
|
1116
|
+
* @implements {ValidationProvider}
|
|
1117
|
+
*/
|
|
1118
|
+
declare class StandardSchemaValidationProvider implements ValidationProvider {
|
|
1119
|
+
/**
|
|
1120
|
+
* Validates data against a schema
|
|
1121
|
+
* @param {ValidationTypes.Schema} schema - The schema to validate against
|
|
1122
|
+
* @param {ValidationTypes.Input} data - The data to validate
|
|
1123
|
+
* @return {ValidationTypes.Result | Promise<ValidationTypes.Result>} The validation result
|
|
1124
|
+
*/
|
|
1125
|
+
validate(schema: ValidationTypes.Schema, data: ValidationTypes.Input): ValidationTypes.Result | Promise<ValidationTypes.Result>;
|
|
1126
|
+
}
|
|
1127
|
+
//#endregion
|
|
1070
1128
|
//#region src/Errors/HttpError.d.ts
|
|
1071
1129
|
/**
|
|
1072
1130
|
* Represents an HTTP error.
|
|
@@ -1212,6 +1270,334 @@ declare class UnauthorizedError extends HttpError {
|
|
|
1212
1270
|
constructor(message?: string);
|
|
1213
1271
|
}
|
|
1214
1272
|
//#endregion
|
|
1273
|
+
//#region src/Types/HttpCodes.d.ts
|
|
1274
|
+
/**
|
|
1275
|
+
* Hypertext Transfer Protocol (HTTP) response status codes.
|
|
1276
|
+
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
|
1277
|
+
*/
|
|
1278
|
+
declare enum HttpStatusCode {
|
|
1279
|
+
/**
|
|
1280
|
+
* The server has received the request headers and the client should proceed to send the request body
|
|
1281
|
+
* (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
1282
|
+
* Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
|
|
1283
|
+
* To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
|
|
1284
|
+
* and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates
|
|
1285
|
+
* the request should not be continued.
|
|
1286
|
+
*/
|
|
1287
|
+
CONTINUE = 100,
|
|
1288
|
+
/**
|
|
1289
|
+
* The requester has asked the server to switch protocols and the server has agreed to do so.
|
|
1290
|
+
*/
|
|
1291
|
+
SWITCHING_PROTOCOLS = 101,
|
|
1292
|
+
/**
|
|
1293
|
+
* A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
|
|
1294
|
+
* This code indicates that the server has received and is processing the request, but no response is available yet.
|
|
1295
|
+
* This prevents the client from timing out and assuming the request was lost.
|
|
1296
|
+
*/
|
|
1297
|
+
PROCESSING = 102,
|
|
1298
|
+
/**
|
|
1299
|
+
* Standard response for successful HTTP requests.
|
|
1300
|
+
* The actual response will depend on the request method used.
|
|
1301
|
+
* In a GET request, the response will contain an entity corresponding to the requested resource.
|
|
1302
|
+
* In a POST request, the response will contain an entity describing or containing the result of the action.
|
|
1303
|
+
*/
|
|
1304
|
+
OK = 200,
|
|
1305
|
+
/**
|
|
1306
|
+
* The request has been fulfilled, resulting in the creation of a new resource.
|
|
1307
|
+
*/
|
|
1308
|
+
CREATED = 201,
|
|
1309
|
+
/**
|
|
1310
|
+
* The request has been accepted for processing, but the processing has not been completed.
|
|
1311
|
+
* The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
|
|
1312
|
+
*/
|
|
1313
|
+
ACCEPTED = 202,
|
|
1314
|
+
/**
|
|
1315
|
+
* SINCE HTTP/1.1
|
|
1316
|
+
* The server is a transforming proxy that received a 200 OK from its origin,
|
|
1317
|
+
* but is returning a modified version of the origin's response.
|
|
1318
|
+
*/
|
|
1319
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
1320
|
+
/**
|
|
1321
|
+
* The server successfully processed the request and is not returning any content.
|
|
1322
|
+
*/
|
|
1323
|
+
NO_CONTENT = 204,
|
|
1324
|
+
/**
|
|
1325
|
+
* The server successfully processed the request, but is not returning any content.
|
|
1326
|
+
* Unlike a 204 response, this response requires that the requester reset the document view.
|
|
1327
|
+
*/
|
|
1328
|
+
RESET_CONTENT = 205,
|
|
1329
|
+
/**
|
|
1330
|
+
* The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
|
|
1331
|
+
* The range header is used by HTTP clients to enable resuming of interrupted downloads,
|
|
1332
|
+
* or split a download into multiple simultaneous streams.
|
|
1333
|
+
*/
|
|
1334
|
+
PARTIAL_CONTENT = 206,
|
|
1335
|
+
/**
|
|
1336
|
+
* The message body that follows is an XML message and can contain a number of separate response codes,
|
|
1337
|
+
* depending on how many sub-requests were made.
|
|
1338
|
+
*/
|
|
1339
|
+
MULTI_STATUS = 207,
|
|
1340
|
+
/**
|
|
1341
|
+
* The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
|
|
1342
|
+
* and are not being included again.
|
|
1343
|
+
*/
|
|
1344
|
+
ALREADY_REPORTED = 208,
|
|
1345
|
+
/**
|
|
1346
|
+
* The server has fulfilled a request for the resource,
|
|
1347
|
+
* and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
|
|
1348
|
+
*/
|
|
1349
|
+
IM_USED = 226,
|
|
1350
|
+
/**
|
|
1351
|
+
* Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
|
|
1352
|
+
* For example, this code could be used to present multiple video format options,
|
|
1353
|
+
* to list files with different filename extensions, or to suggest word-sense disambiguation.
|
|
1354
|
+
*/
|
|
1355
|
+
MULTIPLE_CHOICES = 300,
|
|
1356
|
+
/**
|
|
1357
|
+
* This and all future requests should be directed to the given URI.
|
|
1358
|
+
*/
|
|
1359
|
+
MOVED_PERMANENTLY = 301,
|
|
1360
|
+
/**
|
|
1361
|
+
* This is an example of industry practice contradicting the standard.
|
|
1362
|
+
* The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
|
|
1363
|
+
* (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
|
|
1364
|
+
* with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
|
|
1365
|
+
* to distinguish between the two behaviours. However, some Web applications and frameworks
|
|
1366
|
+
* use the 302 status code as if it were the 303.
|
|
1367
|
+
*/
|
|
1368
|
+
FOUND = 302,
|
|
1369
|
+
/**
|
|
1370
|
+
* SINCE HTTP/1.1
|
|
1371
|
+
* The response to the request can be found under another URI using a GET method.
|
|
1372
|
+
* When received in response to a POST (or PUT/DELETE), the client should presume that
|
|
1373
|
+
* the server has received the data and should issue a redirect with a separate GET message.
|
|
1374
|
+
*/
|
|
1375
|
+
SEE_OTHER = 303,
|
|
1376
|
+
/**
|
|
1377
|
+
* Indicates that the resource has not been modified since the version specified by the request headers
|
|
1378
|
+
* If-Modified-Since or If-None-Match.
|
|
1379
|
+
* In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
|
|
1380
|
+
*/
|
|
1381
|
+
NOT_MODIFIED = 304,
|
|
1382
|
+
/**
|
|
1383
|
+
* SINCE HTTP/1.1
|
|
1384
|
+
* The requested resource is available only through a proxy, the address for which is provided in the response.
|
|
1385
|
+
* Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code,
|
|
1386
|
+
* primarily for security reasons.
|
|
1387
|
+
*/
|
|
1388
|
+
USE_PROXY = 305,
|
|
1389
|
+
/**
|
|
1390
|
+
* No longer used. Originally meant "Subsequent requests should use the specified proxy."
|
|
1391
|
+
*/
|
|
1392
|
+
SWITCH_PROXY = 306,
|
|
1393
|
+
/**
|
|
1394
|
+
* SINCE HTTP/1.1
|
|
1395
|
+
* In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
|
|
1396
|
+
* In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing
|
|
1397
|
+
* the original request.
|
|
1398
|
+
* For example, a POST request should be repeated using another POST request.
|
|
1399
|
+
*/
|
|
1400
|
+
TEMPORARY_REDIRECT = 307,
|
|
1401
|
+
/**
|
|
1402
|
+
* The request and all future requests should be repeated using another URI.
|
|
1403
|
+
* 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
|
|
1404
|
+
* So, for example, submitting a form to a permanently redirected resource may continue smoothly.
|
|
1405
|
+
*/
|
|
1406
|
+
PERMANENT_REDIRECT = 308,
|
|
1407
|
+
/**
|
|
1408
|
+
* The server cannot or will not process the request due to an apparent client error
|
|
1409
|
+
* (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
|
|
1410
|
+
*/
|
|
1411
|
+
BAD_REQUEST = 400,
|
|
1412
|
+
/**
|
|
1413
|
+
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
|
|
1414
|
+
* been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
|
|
1415
|
+
* requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
|
|
1416
|
+
* "unauthenticated",i.e. the user does not have the necessary credentials.
|
|
1417
|
+
*/
|
|
1418
|
+
UNAUTHORIZED = 401,
|
|
1419
|
+
/**
|
|
1420
|
+
* Reserved for future use. The original intention was that this code might be used as part of some form of digital
|
|
1421
|
+
* cash or micro payment scheme, but that has not happened, and this code is not usually used.
|
|
1422
|
+
* Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
|
|
1423
|
+
*/
|
|
1424
|
+
PAYMENT_REQUIRED = 402,
|
|
1425
|
+
/**
|
|
1426
|
+
* The request was valid, but the server is refusing action.
|
|
1427
|
+
* The user might not have the necessary permissions for a resource.
|
|
1428
|
+
*/
|
|
1429
|
+
FORBIDDEN = 403,
|
|
1430
|
+
/**
|
|
1431
|
+
* The requested resource could not be found but may be available in the future.
|
|
1432
|
+
* Subsequent requests by the client are permissible.
|
|
1433
|
+
*/
|
|
1434
|
+
NOT_FOUND = 404,
|
|
1435
|
+
/**
|
|
1436
|
+
* A request method is not supported for the requested resource;
|
|
1437
|
+
* for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
|
|
1438
|
+
*/
|
|
1439
|
+
METHOD_NOT_ALLOWED = 405,
|
|
1440
|
+
/**
|
|
1441
|
+
* The requested resource is capable of generating only content not acceptable according to the Accept
|
|
1442
|
+
* headers sent in the request.
|
|
1443
|
+
*/
|
|
1444
|
+
NOT_ACCEPTABLE = 406,
|
|
1445
|
+
/**
|
|
1446
|
+
* The client must first authenticate itself with the proxy.
|
|
1447
|
+
*/
|
|
1448
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
1449
|
+
/**
|
|
1450
|
+
* The server timed out waiting for the request.
|
|
1451
|
+
* According to HTTP specifications:
|
|
1452
|
+
* "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat
|
|
1453
|
+
* the request without modifications at any later time."
|
|
1454
|
+
*/
|
|
1455
|
+
REQUEST_TIMEOUT = 408,
|
|
1456
|
+
/**
|
|
1457
|
+
* Indicates that the request could not be processed because of conflict in the request,
|
|
1458
|
+
* such as an edit conflict between multiple simultaneous updates.
|
|
1459
|
+
*/
|
|
1460
|
+
CONFLICT = 409,
|
|
1461
|
+
/**
|
|
1462
|
+
* Indicates that the resource requested is no longer available and will not be available again.
|
|
1463
|
+
* This should be used when a resource has been intentionally removed and the resource should be purged.
|
|
1464
|
+
* Upon receiving a 410 status code, the client should not request the resource in the future.
|
|
1465
|
+
* Clients such as search engines should remove the resource from their indices.
|
|
1466
|
+
* Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
|
|
1467
|
+
*/
|
|
1468
|
+
GONE = 410,
|
|
1469
|
+
/**
|
|
1470
|
+
* The request did not specify the length of its content, which is required by the requested resource.
|
|
1471
|
+
*/
|
|
1472
|
+
LENGTH_REQUIRED = 411,
|
|
1473
|
+
/**
|
|
1474
|
+
* The server does not meet one of the preconditions that the requester put on the request.
|
|
1475
|
+
*/
|
|
1476
|
+
PRECONDITION_FAILED = 412,
|
|
1477
|
+
/**
|
|
1478
|
+
* The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
|
|
1479
|
+
*/
|
|
1480
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
1481
|
+
/**
|
|
1482
|
+
* The URI provided was too long for the server to process. Often the result of too much data being encoded
|
|
1483
|
+
* as a query-string of a GET request,
|
|
1484
|
+
* in which case it should be converted to a POST request.
|
|
1485
|
+
* Called "Request-URI Too Long" previously.
|
|
1486
|
+
*/
|
|
1487
|
+
URI_TOO_LONG = 414,
|
|
1488
|
+
/**
|
|
1489
|
+
* The request entity has a media type which the server or resource does not support.
|
|
1490
|
+
* For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
|
|
1491
|
+
*/
|
|
1492
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
1493
|
+
/**
|
|
1494
|
+
* The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
|
|
1495
|
+
* For example, if the client asked for a part of the file that lies beyond the end of the file.
|
|
1496
|
+
* Called "Requested Range Not Satisfiable" previously.
|
|
1497
|
+
*/
|
|
1498
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
1499
|
+
/**
|
|
1500
|
+
* The server cannot meet the requirements of the Expect request-header field.
|
|
1501
|
+
*/
|
|
1502
|
+
EXPECTATION_FAILED = 417,
|
|
1503
|
+
/**
|
|
1504
|
+
* This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324,
|
|
1505
|
+
* Hyper Text Coffee Pot Control Protocol,
|
|
1506
|
+
* and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
|
|
1507
|
+
* teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
|
|
1508
|
+
*/
|
|
1509
|
+
I_AM_A_TEAPOT = 418,
|
|
1510
|
+
/**
|
|
1511
|
+
* The request was directed at a server that is not able to produce a response (for example because a connection reuse).
|
|
1512
|
+
*/
|
|
1513
|
+
MISDIRECTED_REQUEST = 421,
|
|
1514
|
+
/**
|
|
1515
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
1516
|
+
*/
|
|
1517
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
1518
|
+
/**
|
|
1519
|
+
* The resource that is being accessed is locked.
|
|
1520
|
+
*/
|
|
1521
|
+
LOCKED = 423,
|
|
1522
|
+
/**
|
|
1523
|
+
* The request failed due to failure of a previous request (e.g., a PROPPATCH).
|
|
1524
|
+
*/
|
|
1525
|
+
FAILED_DEPENDENCY = 424,
|
|
1526
|
+
/**
|
|
1527
|
+
* The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
|
|
1528
|
+
*/
|
|
1529
|
+
UPGRADE_REQUIRED = 426,
|
|
1530
|
+
/**
|
|
1531
|
+
* The origin server requires the request to be conditional.
|
|
1532
|
+
* Intended to prevent "the 'lost update' problem, where a client
|
|
1533
|
+
* GETs a resource's state, modifies it, and PUTs it back to the server,
|
|
1534
|
+
* when meanwhile a third party has modified the state on the server, leading to a conflict."
|
|
1535
|
+
*/
|
|
1536
|
+
PRECONDITION_REQUIRED = 428,
|
|
1537
|
+
/**
|
|
1538
|
+
* The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
|
|
1539
|
+
*/
|
|
1540
|
+
TOO_MANY_REQUESTS = 429,
|
|
1541
|
+
/**
|
|
1542
|
+
* The server is unwilling to process the request because either an individual header field,
|
|
1543
|
+
* or all the header fields collectively, are too large.
|
|
1544
|
+
*/
|
|
1545
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
1546
|
+
/**
|
|
1547
|
+
* A server operator has received a legal demand to deny access to a resource or to a set of resources
|
|
1548
|
+
* that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
|
|
1549
|
+
*/
|
|
1550
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
1551
|
+
/**
|
|
1552
|
+
* A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
|
|
1553
|
+
*/
|
|
1554
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
1555
|
+
/**
|
|
1556
|
+
* The server either does not recognize the request method, or it lacks the ability to fulfill the request.
|
|
1557
|
+
* Usually this implies future availability (e.g., a new feature of a web-service API).
|
|
1558
|
+
*/
|
|
1559
|
+
NOT_IMPLEMENTED = 501,
|
|
1560
|
+
/**
|
|
1561
|
+
* The server was acting as a gateway or proxy and received an invalid response from the upstream server.
|
|
1562
|
+
*/
|
|
1563
|
+
BAD_GATEWAY = 502,
|
|
1564
|
+
/**
|
|
1565
|
+
* The server is currently unavailable (because it is overloaded or down for maintenance).
|
|
1566
|
+
* Generally, this is a temporary state.
|
|
1567
|
+
*/
|
|
1568
|
+
SERVICE_UNAVAILABLE = 503,
|
|
1569
|
+
/**
|
|
1570
|
+
* The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
|
|
1571
|
+
*/
|
|
1572
|
+
GATEWAY_TIMEOUT = 504,
|
|
1573
|
+
/**
|
|
1574
|
+
* The server does not support the HTTP protocol version used in the request
|
|
1575
|
+
*/
|
|
1576
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
1577
|
+
/**
|
|
1578
|
+
* Transparent content negotiation for the request results in a circular reference.
|
|
1579
|
+
*/
|
|
1580
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
1581
|
+
/**
|
|
1582
|
+
* The server is unable to store the representation needed to complete the request.
|
|
1583
|
+
*/
|
|
1584
|
+
INSUFFICIENT_STORAGE = 507,
|
|
1585
|
+
/**
|
|
1586
|
+
* The server detected an infinite loop while processing the request.
|
|
1587
|
+
*/
|
|
1588
|
+
LOOP_DETECTED = 508,
|
|
1589
|
+
/**
|
|
1590
|
+
* Further extensions to the request are required for the server to fulfill it.
|
|
1591
|
+
*/
|
|
1592
|
+
NOT_EXTENDED = 510,
|
|
1593
|
+
/**
|
|
1594
|
+
* The client needs to authenticate to gain network access.
|
|
1595
|
+
* Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
|
|
1596
|
+
* to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
|
|
1597
|
+
*/
|
|
1598
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
1599
|
+
}
|
|
1600
|
+
//#endregion
|
|
1215
1601
|
//#region src/Utils/Utils.d.ts
|
|
1216
1602
|
/**
|
|
1217
1603
|
* Creates a new metadata context.
|
|
@@ -1235,4 +1621,4 @@ declare function initializeMetadataMethod(target: any, propertyName: string): Me
|
|
|
1235
1621
|
*/
|
|
1236
1622
|
declare function initializeMetadata(target: any): MetadataTypes.Ctx;
|
|
1237
1623
|
//#endregion
|
|
1238
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, ConfigTypes, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers, HooksService, HooksTypes, HttpError, HttpServer, InternalServerError, Listen, MaybePromise, MetadataResolver, MetadataTypes, MethodNotAllowedError, Middleware$1 as Middleware, MiddlewareOptions, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request$1 as Request, Response$1 as Response, Router, RouterTypes, RuntimeConfig$1 as RuntimeConfig, Session, SetHeader, Status, Trace, UnauthorizedError, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
|
1624
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, ConfigTypes, Connect, Controller, CreateAppOptions, DeepPartial, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers, HooksService, HooksTypes, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MaybePromise, MetadataResolver, MetadataTypes, MethodNotAllowedError, Middleware$1 as Middleware, MiddlewareOptions, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request$1 as Request, Response$1 as Response, Router, RouterTypes, RuntimeConfig$1 as RuntimeConfig, Session, SetHeader, StandardSchemaValidationProvider, Status, Trace, UnauthorizedError, ValidationProvider, ValidationTypes, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -36,8 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
}) : target, mod));
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.
|
|
40
|
-
var require_decorate = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.
|
|
39
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.3/node_modules/@oxc-project/runtime/src/helpers/decorate.js
|
|
40
|
+
var require_decorate = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.3/node_modules/@oxc-project/runtime/src/helpers/decorate.js"(exports, module) {
|
|
41
41
|
function __decorate(decorators, target, key, desc) {
|
|
42
42
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
43
43
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -463,7 +463,7 @@ var MetadataResolver = class {
|
|
|
463
463
|
case "headers": return getRequestHeaders(event);
|
|
464
464
|
case "request": return event.request;
|
|
465
465
|
case "response": return event.response;
|
|
466
|
-
case "custom": return arg.
|
|
466
|
+
case "custom": return arg.resolver?.(event);
|
|
467
467
|
case "session": return null;
|
|
468
468
|
default: throw new Error(`Unknown argument type: ${arg.type}`);
|
|
469
469
|
}
|
|
@@ -798,6 +798,20 @@ var HttpServer = class {
|
|
|
798
798
|
*/
|
|
799
799
|
fServer;
|
|
800
800
|
/**
|
|
801
|
+
* List of plugins to be applied to the HTTP server
|
|
802
|
+
* @private
|
|
803
|
+
*/
|
|
804
|
+
fPlugins = [];
|
|
805
|
+
/**
|
|
806
|
+
* Adds a plugin to the HTTP server
|
|
807
|
+
*
|
|
808
|
+
* @param {ServerPlugin} plugin - The plugin to add
|
|
809
|
+
* @returns {void}
|
|
810
|
+
*/
|
|
811
|
+
addPlugin(plugin) {
|
|
812
|
+
this.fPlugins.push(plugin);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
801
815
|
* Initializes the HTTP server and starts listening for requests
|
|
802
816
|
*
|
|
803
817
|
* @returns {Promise<void>} A promise that resolves when the server is ready
|
|
@@ -812,8 +826,10 @@ var HttpServer = class {
|
|
|
812
826
|
return this.gContainer.get(ErrorHandlerProvider).handleError(error);
|
|
813
827
|
} },
|
|
814
828
|
hostname: host,
|
|
829
|
+
reusePort: true,
|
|
815
830
|
port,
|
|
816
|
-
fetch: this.handleRequest.bind(this)
|
|
831
|
+
fetch: this.handleRequest.bind(this),
|
|
832
|
+
plugins: this.fPlugins
|
|
817
833
|
});
|
|
818
834
|
}
|
|
819
835
|
/**
|
|
@@ -938,18 +954,19 @@ var App = class {
|
|
|
938
954
|
*/
|
|
939
955
|
async init(cfg) {
|
|
940
956
|
this.fConfig = cfg;
|
|
957
|
+
await this.resolvePlugins();
|
|
941
958
|
await this.gHttpServer.initialize(this.fConfig);
|
|
942
959
|
if (this.fConfig.server?.static) this.gStaticRequestHandler.initialize(this.fConfig.server?.static);
|
|
943
960
|
if (this.fConfig.runtime) this.gRuntimeConfig.runtimeConfig = this.fConfig.runtime;
|
|
944
961
|
this.gRouter.initialize();
|
|
945
962
|
}
|
|
946
963
|
/**
|
|
947
|
-
*
|
|
964
|
+
* Add new plugin to the application.
|
|
948
965
|
*
|
|
949
|
-
* @param {typeof Plugin} plugin - The plugin to
|
|
966
|
+
* @param {typeof Plugin} plugin - The plugin to add.
|
|
950
967
|
* @param {unknown} options - The options to pass to the plugin.
|
|
951
968
|
*/
|
|
952
|
-
|
|
969
|
+
addPlugin(plugin, options) {
|
|
953
970
|
this.gPluginsRegistry.register(plugin, options);
|
|
954
971
|
}
|
|
955
972
|
/**
|
|
@@ -960,7 +977,6 @@ var App = class {
|
|
|
960
977
|
*/
|
|
961
978
|
async listen() {
|
|
962
979
|
if (this.fIsInitialized) throw new Error("App is already initialized");
|
|
963
|
-
await this.resolvePlugins();
|
|
964
980
|
initializeContainer(this.container);
|
|
965
981
|
await this.gHttpServer.listen();
|
|
966
982
|
this.fIsInitialized = true;
|
|
@@ -1144,7 +1160,7 @@ const defaultConfig = {
|
|
|
1144
1160
|
runtime: { session: {
|
|
1145
1161
|
secret: process.env?.SECRET ?? generateRandomHash(),
|
|
1146
1162
|
name: "vercube_session",
|
|
1147
|
-
duration:
|
|
1163
|
+
duration: 3600 * 24 * 7
|
|
1148
1164
|
} }
|
|
1149
1165
|
};
|
|
1150
1166
|
|
|
@@ -1174,12 +1190,13 @@ async function loadVercubeConfig(overrides) {
|
|
|
1174
1190
|
*
|
|
1175
1191
|
* @returns {Promise<App>} A promise that resolves to an instance of the App.
|
|
1176
1192
|
*/
|
|
1177
|
-
async function createApp(cfg) {
|
|
1193
|
+
async function createApp({ cfg = {}, setup = void 0 } = {}) {
|
|
1178
1194
|
const config = await loadVercubeConfig(cfg);
|
|
1179
1195
|
const container = createContainer(config);
|
|
1180
1196
|
const app = container.resolve(App);
|
|
1181
1197
|
container.get(RuntimeConfig).runtimeConfig = config?.runtime ?? {};
|
|
1182
1198
|
app.container = container;
|
|
1199
|
+
if (setup) await setup(app);
|
|
1183
1200
|
await app.init(config);
|
|
1184
1201
|
initializeContainer(container);
|
|
1185
1202
|
return app;
|
|
@@ -1254,8 +1271,10 @@ function createMetadataMethod() {
|
|
|
1254
1271
|
req: null,
|
|
1255
1272
|
res: null,
|
|
1256
1273
|
url: null,
|
|
1274
|
+
method: null,
|
|
1257
1275
|
args: [],
|
|
1258
|
-
actions: []
|
|
1276
|
+
actions: [],
|
|
1277
|
+
meta: {}
|
|
1259
1278
|
};
|
|
1260
1279
|
}
|
|
1261
1280
|
/**
|
|
@@ -1345,6 +1364,9 @@ var ConnectDecorator = class extends BaseDecorator {
|
|
|
1345
1364
|
* with the Router, and sets up the event handler for the CONNECT request.
|
|
1346
1365
|
*/
|
|
1347
1366
|
created() {
|
|
1367
|
+
initializeMetadata(this.prototype);
|
|
1368
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1369
|
+
method.method = "CONNECT";
|
|
1348
1370
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1349
1371
|
instance: this.instance,
|
|
1350
1372
|
path: this.options.path,
|
|
@@ -1421,7 +1443,8 @@ var DeleteDecorator = class extends BaseDecorator {
|
|
|
1421
1443
|
*/
|
|
1422
1444
|
created() {
|
|
1423
1445
|
initializeMetadata(this.prototype);
|
|
1424
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1446
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1447
|
+
method.method = "DELETE";
|
|
1425
1448
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1426
1449
|
instance: this.instance,
|
|
1427
1450
|
path: this.options.path,
|
|
@@ -1477,7 +1500,8 @@ var GetDecorator = class extends BaseDecorator {
|
|
|
1477
1500
|
*/
|
|
1478
1501
|
created() {
|
|
1479
1502
|
initializeMetadata(this.prototype);
|
|
1480
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1503
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1504
|
+
method.method = "GET";
|
|
1481
1505
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1482
1506
|
instance: this.instance,
|
|
1483
1507
|
path: this.options.path,
|
|
@@ -1533,7 +1557,8 @@ var HeadDecorator = class extends BaseDecorator {
|
|
|
1533
1557
|
*/
|
|
1534
1558
|
created() {
|
|
1535
1559
|
initializeMetadata(this.prototype);
|
|
1536
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1560
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1561
|
+
method.method = "HEAD";
|
|
1537
1562
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1538
1563
|
instance: this.instance,
|
|
1539
1564
|
path: this.options.path,
|
|
@@ -1670,7 +1695,8 @@ var OptionsDecorator = class extends BaseDecorator {
|
|
|
1670
1695
|
*/
|
|
1671
1696
|
created() {
|
|
1672
1697
|
initializeMetadata(this.prototype);
|
|
1673
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1698
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1699
|
+
method.method = "OPTIONS";
|
|
1674
1700
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1675
1701
|
instance: this.instance,
|
|
1676
1702
|
path: this.options.path,
|
|
@@ -1771,6 +1797,9 @@ var PatchDecorator = class extends BaseDecorator {
|
|
|
1771
1797
|
* with the Router, and sets up the event handler for the PATCH request.
|
|
1772
1798
|
*/
|
|
1773
1799
|
created() {
|
|
1800
|
+
initializeMetadata(this.prototype);
|
|
1801
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1802
|
+
method.method = "PATCH";
|
|
1774
1803
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1775
1804
|
instance: this.instance,
|
|
1776
1805
|
path: this.options.path,
|
|
@@ -1826,7 +1855,8 @@ var PostDecorator = class extends BaseDecorator {
|
|
|
1826
1855
|
*/
|
|
1827
1856
|
created() {
|
|
1828
1857
|
initializeMetadata(this.prototype);
|
|
1829
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1858
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1859
|
+
method.method = "POST";
|
|
1830
1860
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1831
1861
|
instance: this.instance,
|
|
1832
1862
|
path: this.options.path,
|
|
@@ -1882,7 +1912,8 @@ var PutDecorator = class extends BaseDecorator {
|
|
|
1882
1912
|
*/
|
|
1883
1913
|
created() {
|
|
1884
1914
|
initializeMetadata(this.prototype);
|
|
1885
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1915
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
1916
|
+
method.method = "PUT";
|
|
1886
1917
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
1887
1918
|
instance: this.instance,
|
|
1888
1919
|
path: this.options.path,
|
|
@@ -2114,7 +2145,8 @@ var TraceDecorator = class extends BaseDecorator {
|
|
|
2114
2145
|
*/
|
|
2115
2146
|
created() {
|
|
2116
2147
|
initializeMetadata(this.prototype);
|
|
2117
|
-
initializeMetadataMethod(this.prototype, this.propertyName);
|
|
2148
|
+
const method = initializeMetadataMethod(this.prototype, this.propertyName);
|
|
2149
|
+
method.method = "TRACE";
|
|
2118
2150
|
this.options.path = this.gMetadataResolver.resolveUrl({
|
|
2119
2151
|
instance: this.instance,
|
|
2120
2152
|
path: this.options.path,
|
|
@@ -2368,7 +2400,7 @@ var SessionDecorator = class extends BaseDecorator {
|
|
|
2368
2400
|
data: {
|
|
2369
2401
|
name: this.gRuntimeConfig.runtimeConfig.session?.name ?? "vercube_session",
|
|
2370
2402
|
secret: this.gRuntimeConfig.runtimeConfig.session?.secret ?? generateRandomHash(),
|
|
2371
|
-
duration: this.gRuntimeConfig.runtimeConfig.session?.duration ??
|
|
2403
|
+
duration: this.gRuntimeConfig.runtimeConfig.session?.duration ?? 3600 * 24 * 7
|
|
2372
2404
|
}
|
|
2373
2405
|
});
|
|
2374
2406
|
}
|
|
@@ -2629,4 +2661,334 @@ let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
|
2629
2661
|
}({});
|
|
2630
2662
|
|
|
2631
2663
|
//#endregion
|
|
2632
|
-
|
|
2664
|
+
//#region src/Types/HttpCodes.ts
|
|
2665
|
+
/**
|
|
2666
|
+
* Hypertext Transfer Protocol (HTTP) response status codes.
|
|
2667
|
+
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
|
2668
|
+
*/
|
|
2669
|
+
let HttpStatusCode = /* @__PURE__ */ function(HttpStatusCode$1) {
|
|
2670
|
+
/**
|
|
2671
|
+
* The server has received the request headers and the client should proceed to send the request body
|
|
2672
|
+
* (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
2673
|
+
* Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
|
|
2674
|
+
* To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
|
|
2675
|
+
* and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates
|
|
2676
|
+
* the request should not be continued.
|
|
2677
|
+
*/
|
|
2678
|
+
HttpStatusCode$1[HttpStatusCode$1["CONTINUE"] = 100] = "CONTINUE";
|
|
2679
|
+
/**
|
|
2680
|
+
* The requester has asked the server to switch protocols and the server has agreed to do so.
|
|
2681
|
+
*/
|
|
2682
|
+
HttpStatusCode$1[HttpStatusCode$1["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
2683
|
+
/**
|
|
2684
|
+
* A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
|
|
2685
|
+
* This code indicates that the server has received and is processing the request, but no response is available yet.
|
|
2686
|
+
* This prevents the client from timing out and assuming the request was lost.
|
|
2687
|
+
*/
|
|
2688
|
+
HttpStatusCode$1[HttpStatusCode$1["PROCESSING"] = 102] = "PROCESSING";
|
|
2689
|
+
/**
|
|
2690
|
+
* Standard response for successful HTTP requests.
|
|
2691
|
+
* The actual response will depend on the request method used.
|
|
2692
|
+
* In a GET request, the response will contain an entity corresponding to the requested resource.
|
|
2693
|
+
* In a POST request, the response will contain an entity describing or containing the result of the action.
|
|
2694
|
+
*/
|
|
2695
|
+
HttpStatusCode$1[HttpStatusCode$1["OK"] = 200] = "OK";
|
|
2696
|
+
/**
|
|
2697
|
+
* The request has been fulfilled, resulting in the creation of a new resource.
|
|
2698
|
+
*/
|
|
2699
|
+
HttpStatusCode$1[HttpStatusCode$1["CREATED"] = 201] = "CREATED";
|
|
2700
|
+
/**
|
|
2701
|
+
* The request has been accepted for processing, but the processing has not been completed.
|
|
2702
|
+
* The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
|
|
2703
|
+
*/
|
|
2704
|
+
HttpStatusCode$1[HttpStatusCode$1["ACCEPTED"] = 202] = "ACCEPTED";
|
|
2705
|
+
/**
|
|
2706
|
+
* SINCE HTTP/1.1
|
|
2707
|
+
* The server is a transforming proxy that received a 200 OK from its origin,
|
|
2708
|
+
* but is returning a modified version of the origin's response.
|
|
2709
|
+
*/
|
|
2710
|
+
HttpStatusCode$1[HttpStatusCode$1["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
2711
|
+
/**
|
|
2712
|
+
* The server successfully processed the request and is not returning any content.
|
|
2713
|
+
*/
|
|
2714
|
+
HttpStatusCode$1[HttpStatusCode$1["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
2715
|
+
/**
|
|
2716
|
+
* The server successfully processed the request, but is not returning any content.
|
|
2717
|
+
* Unlike a 204 response, this response requires that the requester reset the document view.
|
|
2718
|
+
*/
|
|
2719
|
+
HttpStatusCode$1[HttpStatusCode$1["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
2720
|
+
/**
|
|
2721
|
+
* The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
|
|
2722
|
+
* The range header is used by HTTP clients to enable resuming of interrupted downloads,
|
|
2723
|
+
* or split a download into multiple simultaneous streams.
|
|
2724
|
+
*/
|
|
2725
|
+
HttpStatusCode$1[HttpStatusCode$1["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
2726
|
+
/**
|
|
2727
|
+
* The message body that follows is an XML message and can contain a number of separate response codes,
|
|
2728
|
+
* depending on how many sub-requests were made.
|
|
2729
|
+
*/
|
|
2730
|
+
HttpStatusCode$1[HttpStatusCode$1["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
2731
|
+
/**
|
|
2732
|
+
* The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
|
|
2733
|
+
* and are not being included again.
|
|
2734
|
+
*/
|
|
2735
|
+
HttpStatusCode$1[HttpStatusCode$1["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
2736
|
+
/**
|
|
2737
|
+
* The server has fulfilled a request for the resource,
|
|
2738
|
+
* and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
|
|
2739
|
+
*/
|
|
2740
|
+
HttpStatusCode$1[HttpStatusCode$1["IM_USED"] = 226] = "IM_USED";
|
|
2741
|
+
/**
|
|
2742
|
+
* Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
|
|
2743
|
+
* For example, this code could be used to present multiple video format options,
|
|
2744
|
+
* to list files with different filename extensions, or to suggest word-sense disambiguation.
|
|
2745
|
+
*/
|
|
2746
|
+
HttpStatusCode$1[HttpStatusCode$1["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
2747
|
+
/**
|
|
2748
|
+
* This and all future requests should be directed to the given URI.
|
|
2749
|
+
*/
|
|
2750
|
+
HttpStatusCode$1[HttpStatusCode$1["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
2751
|
+
/**
|
|
2752
|
+
* This is an example of industry practice contradicting the standard.
|
|
2753
|
+
* The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
|
|
2754
|
+
* (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
|
|
2755
|
+
* with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
|
|
2756
|
+
* to distinguish between the two behaviours. However, some Web applications and frameworks
|
|
2757
|
+
* use the 302 status code as if it were the 303.
|
|
2758
|
+
*/
|
|
2759
|
+
HttpStatusCode$1[HttpStatusCode$1["FOUND"] = 302] = "FOUND";
|
|
2760
|
+
/**
|
|
2761
|
+
* SINCE HTTP/1.1
|
|
2762
|
+
* The response to the request can be found under another URI using a GET method.
|
|
2763
|
+
* When received in response to a POST (or PUT/DELETE), the client should presume that
|
|
2764
|
+
* the server has received the data and should issue a redirect with a separate GET message.
|
|
2765
|
+
*/
|
|
2766
|
+
HttpStatusCode$1[HttpStatusCode$1["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
2767
|
+
/**
|
|
2768
|
+
* Indicates that the resource has not been modified since the version specified by the request headers
|
|
2769
|
+
* If-Modified-Since or If-None-Match.
|
|
2770
|
+
* In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
|
|
2771
|
+
*/
|
|
2772
|
+
HttpStatusCode$1[HttpStatusCode$1["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
2773
|
+
/**
|
|
2774
|
+
* SINCE HTTP/1.1
|
|
2775
|
+
* The requested resource is available only through a proxy, the address for which is provided in the response.
|
|
2776
|
+
* Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code,
|
|
2777
|
+
* primarily for security reasons.
|
|
2778
|
+
*/
|
|
2779
|
+
HttpStatusCode$1[HttpStatusCode$1["USE_PROXY"] = 305] = "USE_PROXY";
|
|
2780
|
+
/**
|
|
2781
|
+
* No longer used. Originally meant "Subsequent requests should use the specified proxy."
|
|
2782
|
+
*/
|
|
2783
|
+
HttpStatusCode$1[HttpStatusCode$1["SWITCH_PROXY"] = 306] = "SWITCH_PROXY";
|
|
2784
|
+
/**
|
|
2785
|
+
* SINCE HTTP/1.1
|
|
2786
|
+
* In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
|
|
2787
|
+
* In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing
|
|
2788
|
+
* the original request.
|
|
2789
|
+
* For example, a POST request should be repeated using another POST request.
|
|
2790
|
+
*/
|
|
2791
|
+
HttpStatusCode$1[HttpStatusCode$1["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
2792
|
+
/**
|
|
2793
|
+
* The request and all future requests should be repeated using another URI.
|
|
2794
|
+
* 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
|
|
2795
|
+
* So, for example, submitting a form to a permanently redirected resource may continue smoothly.
|
|
2796
|
+
*/
|
|
2797
|
+
HttpStatusCode$1[HttpStatusCode$1["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
2798
|
+
/**
|
|
2799
|
+
* The server cannot or will not process the request due to an apparent client error
|
|
2800
|
+
* (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
|
|
2801
|
+
*/
|
|
2802
|
+
HttpStatusCode$1[HttpStatusCode$1["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
2803
|
+
/**
|
|
2804
|
+
* Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
|
|
2805
|
+
* been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
|
|
2806
|
+
* requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
|
|
2807
|
+
* "unauthenticated",i.e. the user does not have the necessary credentials.
|
|
2808
|
+
*/
|
|
2809
|
+
HttpStatusCode$1[HttpStatusCode$1["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
2810
|
+
/**
|
|
2811
|
+
* Reserved for future use. The original intention was that this code might be used as part of some form of digital
|
|
2812
|
+
* cash or micro payment scheme, but that has not happened, and this code is not usually used.
|
|
2813
|
+
* Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
|
|
2814
|
+
*/
|
|
2815
|
+
HttpStatusCode$1[HttpStatusCode$1["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
2816
|
+
/**
|
|
2817
|
+
* The request was valid, but the server is refusing action.
|
|
2818
|
+
* The user might not have the necessary permissions for a resource.
|
|
2819
|
+
*/
|
|
2820
|
+
HttpStatusCode$1[HttpStatusCode$1["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
2821
|
+
/**
|
|
2822
|
+
* The requested resource could not be found but may be available in the future.
|
|
2823
|
+
* Subsequent requests by the client are permissible.
|
|
2824
|
+
*/
|
|
2825
|
+
HttpStatusCode$1[HttpStatusCode$1["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
2826
|
+
/**
|
|
2827
|
+
* A request method is not supported for the requested resource;
|
|
2828
|
+
* for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
|
|
2829
|
+
*/
|
|
2830
|
+
HttpStatusCode$1[HttpStatusCode$1["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
2831
|
+
/**
|
|
2832
|
+
* The requested resource is capable of generating only content not acceptable according to the Accept
|
|
2833
|
+
* headers sent in the request.
|
|
2834
|
+
*/
|
|
2835
|
+
HttpStatusCode$1[HttpStatusCode$1["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
2836
|
+
/**
|
|
2837
|
+
* The client must first authenticate itself with the proxy.
|
|
2838
|
+
*/
|
|
2839
|
+
HttpStatusCode$1[HttpStatusCode$1["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
2840
|
+
/**
|
|
2841
|
+
* The server timed out waiting for the request.
|
|
2842
|
+
* According to HTTP specifications:
|
|
2843
|
+
* "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat
|
|
2844
|
+
* the request without modifications at any later time."
|
|
2845
|
+
*/
|
|
2846
|
+
HttpStatusCode$1[HttpStatusCode$1["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
2847
|
+
/**
|
|
2848
|
+
* Indicates that the request could not be processed because of conflict in the request,
|
|
2849
|
+
* such as an edit conflict between multiple simultaneous updates.
|
|
2850
|
+
*/
|
|
2851
|
+
HttpStatusCode$1[HttpStatusCode$1["CONFLICT"] = 409] = "CONFLICT";
|
|
2852
|
+
/**
|
|
2853
|
+
* Indicates that the resource requested is no longer available and will not be available again.
|
|
2854
|
+
* This should be used when a resource has been intentionally removed and the resource should be purged.
|
|
2855
|
+
* Upon receiving a 410 status code, the client should not request the resource in the future.
|
|
2856
|
+
* Clients such as search engines should remove the resource from their indices.
|
|
2857
|
+
* Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
|
|
2858
|
+
*/
|
|
2859
|
+
HttpStatusCode$1[HttpStatusCode$1["GONE"] = 410] = "GONE";
|
|
2860
|
+
/**
|
|
2861
|
+
* The request did not specify the length of its content, which is required by the requested resource.
|
|
2862
|
+
*/
|
|
2863
|
+
HttpStatusCode$1[HttpStatusCode$1["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
2864
|
+
/**
|
|
2865
|
+
* The server does not meet one of the preconditions that the requester put on the request.
|
|
2866
|
+
*/
|
|
2867
|
+
HttpStatusCode$1[HttpStatusCode$1["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
2868
|
+
/**
|
|
2869
|
+
* The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
|
|
2870
|
+
*/
|
|
2871
|
+
HttpStatusCode$1[HttpStatusCode$1["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
2872
|
+
/**
|
|
2873
|
+
* The URI provided was too long for the server to process. Often the result of too much data being encoded
|
|
2874
|
+
* as a query-string of a GET request,
|
|
2875
|
+
* in which case it should be converted to a POST request.
|
|
2876
|
+
* Called "Request-URI Too Long" previously.
|
|
2877
|
+
*/
|
|
2878
|
+
HttpStatusCode$1[HttpStatusCode$1["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
2879
|
+
/**
|
|
2880
|
+
* The request entity has a media type which the server or resource does not support.
|
|
2881
|
+
* For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
|
|
2882
|
+
*/
|
|
2883
|
+
HttpStatusCode$1[HttpStatusCode$1["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
2884
|
+
/**
|
|
2885
|
+
* The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
|
|
2886
|
+
* For example, if the client asked for a part of the file that lies beyond the end of the file.
|
|
2887
|
+
* Called "Requested Range Not Satisfiable" previously.
|
|
2888
|
+
*/
|
|
2889
|
+
HttpStatusCode$1[HttpStatusCode$1["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
2890
|
+
/**
|
|
2891
|
+
* The server cannot meet the requirements of the Expect request-header field.
|
|
2892
|
+
*/
|
|
2893
|
+
HttpStatusCode$1[HttpStatusCode$1["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
2894
|
+
/**
|
|
2895
|
+
* This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324,
|
|
2896
|
+
* Hyper Text Coffee Pot Control Protocol,
|
|
2897
|
+
* and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
|
|
2898
|
+
* teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
|
|
2899
|
+
*/
|
|
2900
|
+
HttpStatusCode$1[HttpStatusCode$1["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
2901
|
+
/**
|
|
2902
|
+
* The request was directed at a server that is not able to produce a response (for example because a connection reuse).
|
|
2903
|
+
*/
|
|
2904
|
+
HttpStatusCode$1[HttpStatusCode$1["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
2905
|
+
/**
|
|
2906
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
2907
|
+
*/
|
|
2908
|
+
HttpStatusCode$1[HttpStatusCode$1["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
2909
|
+
/**
|
|
2910
|
+
* The resource that is being accessed is locked.
|
|
2911
|
+
*/
|
|
2912
|
+
HttpStatusCode$1[HttpStatusCode$1["LOCKED"] = 423] = "LOCKED";
|
|
2913
|
+
/**
|
|
2914
|
+
* The request failed due to failure of a previous request (e.g., a PROPPATCH).
|
|
2915
|
+
*/
|
|
2916
|
+
HttpStatusCode$1[HttpStatusCode$1["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
2917
|
+
/**
|
|
2918
|
+
* The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
|
|
2919
|
+
*/
|
|
2920
|
+
HttpStatusCode$1[HttpStatusCode$1["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
2921
|
+
/**
|
|
2922
|
+
* The origin server requires the request to be conditional.
|
|
2923
|
+
* Intended to prevent "the 'lost update' problem, where a client
|
|
2924
|
+
* GETs a resource's state, modifies it, and PUTs it back to the server,
|
|
2925
|
+
* when meanwhile a third party has modified the state on the server, leading to a conflict."
|
|
2926
|
+
*/
|
|
2927
|
+
HttpStatusCode$1[HttpStatusCode$1["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
2928
|
+
/**
|
|
2929
|
+
* The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
|
|
2930
|
+
*/
|
|
2931
|
+
HttpStatusCode$1[HttpStatusCode$1["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
2932
|
+
/**
|
|
2933
|
+
* The server is unwilling to process the request because either an individual header field,
|
|
2934
|
+
* or all the header fields collectively, are too large.
|
|
2935
|
+
*/
|
|
2936
|
+
HttpStatusCode$1[HttpStatusCode$1["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
2937
|
+
/**
|
|
2938
|
+
* A server operator has received a legal demand to deny access to a resource or to a set of resources
|
|
2939
|
+
* that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
|
|
2940
|
+
*/
|
|
2941
|
+
HttpStatusCode$1[HttpStatusCode$1["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
2942
|
+
/**
|
|
2943
|
+
* A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
|
|
2944
|
+
*/
|
|
2945
|
+
HttpStatusCode$1[HttpStatusCode$1["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
2946
|
+
/**
|
|
2947
|
+
* The server either does not recognize the request method, or it lacks the ability to fulfill the request.
|
|
2948
|
+
* Usually this implies future availability (e.g., a new feature of a web-service API).
|
|
2949
|
+
*/
|
|
2950
|
+
HttpStatusCode$1[HttpStatusCode$1["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
2951
|
+
/**
|
|
2952
|
+
* The server was acting as a gateway or proxy and received an invalid response from the upstream server.
|
|
2953
|
+
*/
|
|
2954
|
+
HttpStatusCode$1[HttpStatusCode$1["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
2955
|
+
/**
|
|
2956
|
+
* The server is currently unavailable (because it is overloaded or down for maintenance).
|
|
2957
|
+
* Generally, this is a temporary state.
|
|
2958
|
+
*/
|
|
2959
|
+
HttpStatusCode$1[HttpStatusCode$1["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
2960
|
+
/**
|
|
2961
|
+
* The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
|
|
2962
|
+
*/
|
|
2963
|
+
HttpStatusCode$1[HttpStatusCode$1["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
2964
|
+
/**
|
|
2965
|
+
* The server does not support the HTTP protocol version used in the request
|
|
2966
|
+
*/
|
|
2967
|
+
HttpStatusCode$1[HttpStatusCode$1["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
2968
|
+
/**
|
|
2969
|
+
* Transparent content negotiation for the request results in a circular reference.
|
|
2970
|
+
*/
|
|
2971
|
+
HttpStatusCode$1[HttpStatusCode$1["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
2972
|
+
/**
|
|
2973
|
+
* The server is unable to store the representation needed to complete the request.
|
|
2974
|
+
*/
|
|
2975
|
+
HttpStatusCode$1[HttpStatusCode$1["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
2976
|
+
/**
|
|
2977
|
+
* The server detected an infinite loop while processing the request.
|
|
2978
|
+
*/
|
|
2979
|
+
HttpStatusCode$1[HttpStatusCode$1["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
2980
|
+
/**
|
|
2981
|
+
* Further extensions to the request are required for the server to fulfill it.
|
|
2982
|
+
*/
|
|
2983
|
+
HttpStatusCode$1[HttpStatusCode$1["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
2984
|
+
/**
|
|
2985
|
+
* The client needs to authenticate to gain network access.
|
|
2986
|
+
* Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
|
|
2987
|
+
* to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
|
|
2988
|
+
*/
|
|
2989
|
+
HttpStatusCode$1[HttpStatusCode$1["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
2990
|
+
return HttpStatusCode$1;
|
|
2991
|
+
}({});
|
|
2992
|
+
|
|
2993
|
+
//#endregion
|
|
2994
|
+
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, Session, SetHeader, StandardSchemaValidationProvider, Status, Trace, UnauthorizedError, ValidationProvider, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Core module for Vercube framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"pathe": "2.0.3",
|
|
29
29
|
"rou3": "0.7.3",
|
|
30
30
|
"srvx": "0.8.2",
|
|
31
|
-
"@vercube/di": "0.0.
|
|
32
|
-
"@vercube/logger": "0.0.
|
|
31
|
+
"@vercube/di": "0.0.20",
|
|
32
|
+
"@vercube/logger": "0.0.20"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|