@vercube/core 0.0.1-beta.0 → 0.0.1-beta.2
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/LICENSE +21 -0
- package/dist/Decorators/Http/QueryParams.d.ts +1 -1
- package/dist/Types/MetadataTypes.d.ts +3 -1
- package/dist/Types/RouterTypes.d.ts +37 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +2 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present - Vercube
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -11,5 +11,5 @@ interface QueryParamsDecoratorOptions {
|
|
|
11
11
|
* @param {QueryParamsDecoratorOptions} options - The options for the decorator.
|
|
12
12
|
* @return {Function} The decorator function.
|
|
13
13
|
*/
|
|
14
|
-
export declare function QueryParams(options
|
|
14
|
+
export declare function QueryParams(options?: QueryParamsDecoratorOptions): Function;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseMiddleware } from "../Services/Middleware/BaseMiddleware.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { RouterTypes } from "./RouterTypes.js";
|
|
3
|
+
import type { ValidationTypes } from "./ValidationTypes.js";
|
|
3
4
|
export declare namespace MetadataTypes {
|
|
4
5
|
interface Metadata {
|
|
5
6
|
__metadata: Ctx;
|
|
@@ -30,6 +31,7 @@ export declare namespace MetadataTypes {
|
|
|
30
31
|
idx: number;
|
|
31
32
|
type: string;
|
|
32
33
|
data?: Record<string, any>;
|
|
34
|
+
resolver?: (event: RouterTypes.RouterEvent) => Promise<unknown>;
|
|
33
35
|
resolved?: unknown;
|
|
34
36
|
validate?: boolean;
|
|
35
37
|
validationSchema?: ValidationTypes.Schema;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MetadataTypes } from "./MetadataTypes.js";
|
|
2
|
+
import { BaseMiddleware } from "../Services/Middleware/BaseMiddleware.js";
|
|
3
|
+
export declare namespace RouterTypes {
|
|
4
|
+
interface Route {
|
|
5
|
+
path: string;
|
|
6
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD" | "CONNECT" | "TRACE";
|
|
7
|
+
handler: RouterHandler;
|
|
8
|
+
}
|
|
9
|
+
interface RouteFind {
|
|
10
|
+
path: string;
|
|
11
|
+
method: string;
|
|
12
|
+
}
|
|
13
|
+
interface MiddlewareDefinition {
|
|
14
|
+
middleware: BaseMiddleware<unknown, unknown>;
|
|
15
|
+
target: string;
|
|
16
|
+
priority?: number;
|
|
17
|
+
args?: unknown;
|
|
18
|
+
}
|
|
19
|
+
interface RouterHandler {
|
|
20
|
+
instance: any;
|
|
21
|
+
propertyName: string;
|
|
22
|
+
args: MetadataTypes.Arg[];
|
|
23
|
+
middlewares: {
|
|
24
|
+
beforeMiddlewares: MiddlewareDefinition[]
|
|
25
|
+
afterMiddlewares: MiddlewareDefinition[]
|
|
26
|
+
};
|
|
27
|
+
actions: MetadataTypes.Action[];
|
|
28
|
+
}
|
|
29
|
+
interface RouteMatched<T = unknown> {
|
|
30
|
+
data: T;
|
|
31
|
+
params?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
type RouterEvent = RouterTypes.RouteMatched<RouterTypes.RouterHandler> & {
|
|
34
|
+
request: Request
|
|
35
|
+
response: Response
|
|
36
|
+
};
|
|
37
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -386,6 +386,7 @@ var MetadataResolver = class {
|
|
|
386
386
|
case "headers": return getRequestHeaders(event);
|
|
387
387
|
case "request": return event.request;
|
|
388
388
|
case "response": return event.response;
|
|
389
|
+
case "custom": return arg.data?.resolve(event);
|
|
389
390
|
case "session": return null;
|
|
390
391
|
default: throw new Error(`Unknown argument type: ${arg.type}`);
|
|
391
392
|
}
|
|
@@ -1999,6 +2000,7 @@ exports.HttpError = HttpError
|
|
|
1999
2000
|
exports.HttpServer = HttpServer
|
|
2000
2001
|
exports.InternalServerError = InternalServerError
|
|
2001
2002
|
exports.Listen = Listen
|
|
2003
|
+
exports.MetadataResolver = MetadataResolver
|
|
2002
2004
|
exports.MethodNotAllowedError = MethodNotAllowedError
|
|
2003
2005
|
exports.Middleware = Middleware
|
|
2004
2006
|
exports.MultipartFormData = MultipartFormData
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from "./Services/Hooks/HooksService.js";
|
|
|
31
31
|
export * from "./Services/Plugins/BasePlugin.js";
|
|
32
32
|
export * from "./Services/Middleware/BaseMiddleware.js";
|
|
33
33
|
export * from "./Services/HttpServer/HttpServer.js";
|
|
34
|
+
export * from "./Services/Metadata/MetadataResolver.js";
|
|
34
35
|
export * from "./Errors/HttpError.js";
|
|
35
36
|
export * from "./Errors/Http/BadRequestError.js";
|
|
36
37
|
export * from "./Errors/Http/ForbiddenError.js";
|
|
@@ -44,4 +45,5 @@ export * from "./Types/HooksTypes.js";
|
|
|
44
45
|
export * from "./Types/HttpTypes.js";
|
|
45
46
|
export * from "./Types/MetadataTypes.js";
|
|
46
47
|
export * from "./Types/ConfigTypes.js";
|
|
48
|
+
export * from "./Types/RouterTypes.js";
|
|
47
49
|
export * from "./Utils/Utils.js";
|
package/dist/index.mjs
CHANGED
|
@@ -356,6 +356,7 @@ var MetadataResolver = class {
|
|
|
356
356
|
case "headers": return getRequestHeaders(event);
|
|
357
357
|
case "request": return event.request;
|
|
358
358
|
case "response": return event.response;
|
|
359
|
+
case "custom": return arg.data?.resolve(event);
|
|
359
360
|
case "session": return null;
|
|
360
361
|
default: throw new Error(`Unknown argument type: ${arg.type}`);
|
|
361
362
|
}
|
|
@@ -1950,4 +1951,4 @@ let HTTPStatus = /* @__PURE__ */ function(HTTPStatus$1) {
|
|
|
1950
1951
|
}({});
|
|
1951
1952
|
|
|
1952
1953
|
//#endregion
|
|
1953
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ForbiddenError, Get, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, InternalServerError, Listen, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Session, SetHeader, Status, Trace, UnauthorizedError, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
|
1954
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ForbiddenError, Get, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, Response$1 as Response, Session, SetHeader, Status, Trace, UnauthorizedError, 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.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.2",
|
|
4
4
|
"description": "Core module for Vercube framework",
|
|
5
5
|
"repository": "@vercube/core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"pathe": "2.0.3",
|
|
27
27
|
"rou3": "0.5.1",
|
|
28
28
|
"srvx": "0.2.8",
|
|
29
|
-
"@vercube/di": "0.0.1-beta.
|
|
30
|
-
"@vercube/logger": "0.0.1-beta.
|
|
29
|
+
"@vercube/di": "0.0.1-beta.2",
|
|
30
|
+
"@vercube/logger": "0.0.1-beta.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@vitest/coverage-v8": "^1.3.1",
|