tspace-spear 1.2.7 → 1.2.9-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +347 -155
- package/dist/cli/generators/app/index.d.ts +1 -0
- package/dist/cli/generators/app/index.js +124 -0
- package/dist/cli/generators/app/index.js.map +1 -0
- package/dist/cli/generators/app/template.d.ts +1 -0
- package/dist/cli/generators/app/template.js +42 -0
- package/dist/cli/generators/app/template.js.map +1 -0
- package/dist/cli/generators/client/template.d.ts +1 -0
- package/dist/cli/generators/client/template.js +30 -0
- package/dist/cli/generators/client/template.js.map +1 -0
- package/dist/cli/generators/controller/index.d.ts +1 -0
- package/dist/cli/generators/controller/index.js +78 -0
- package/dist/cli/generators/controller/index.js.map +1 -0
- package/dist/cli/generators/controller/template.d.ts +1 -0
- package/dist/cli/generators/controller/template.js +108 -0
- package/dist/cli/generators/controller/template.js.map +1 -0
- package/dist/cli/generators/dto/index.d.ts +1 -0
- package/dist/cli/generators/dto/index.js +57 -0
- package/dist/cli/generators/dto/index.js.map +1 -0
- package/dist/cli/generators/dto/template.d.ts +1 -0
- package/dist/cli/generators/dto/template.js +32 -0
- package/dist/cli/generators/dto/template.js.map +1 -0
- package/dist/cli/generators/middleware/index.d.ts +1 -0
- package/dist/cli/generators/middleware/index.js +38 -0
- package/dist/cli/generators/middleware/index.js.map +1 -0
- package/dist/cli/generators/middleware/template.d.ts +1 -0
- package/dist/cli/generators/middleware/template.js +16 -0
- package/dist/cli/generators/middleware/template.js.map +1 -0
- package/dist/cli/generators/module/index.d.ts +1 -0
- package/dist/cli/generators/module/index.js +173 -0
- package/dist/cli/generators/module/index.js.map +1 -0
- package/dist/cli/generators/service/index.d.ts +1 -0
- package/dist/cli/generators/service/index.js +53 -0
- package/dist/cli/generators/service/index.js.map +1 -0
- package/dist/cli/generators/service/template.d.ts +1 -0
- package/dist/cli/generators/service/template.js +74 -0
- package/dist/cli/generators/service/template.js.map +1 -0
- package/dist/cli/generators/shared/index.d.ts +3 -0
- package/dist/cli/generators/shared/index.js +22 -0
- package/dist/cli/generators/shared/index.js.map +1 -0
- package/dist/cli/index.js +55 -96
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/core/client/index.d.ts +13 -43
- package/dist/lib/core/client/index.js +70 -33
- package/dist/lib/core/client/index.js.map +1 -1
- package/dist/lib/core/client/types.d.ts +43 -0
- package/dist/lib/core/client/types.js +3 -0
- package/dist/lib/core/client/types.js.map +1 -0
- package/dist/lib/core/compiler/generator.d.ts +4 -6
- package/dist/lib/core/compiler/generator.js +190 -39
- package/dist/lib/core/compiler/generator.js.map +1 -1
- package/dist/lib/core/compiler/index.d.ts +2 -2
- package/dist/lib/core/compiler/index.js +2 -2
- package/dist/lib/core/compiler/index.js.map +1 -1
- package/dist/lib/core/compiler/pre-routes.d.ts +12 -130
- package/dist/lib/core/compiler/pre-routes.js +13 -35
- package/dist/lib/core/compiler/pre-routes.js.map +1 -1
- package/dist/lib/core/compiler/types.d.ts +25 -0
- package/dist/lib/core/decorators/context.d.ts +78 -8
- package/dist/lib/core/decorators/context.js +84 -9
- package/dist/lib/core/decorators/context.js.map +1 -1
- package/dist/lib/core/decorators/controller.js +2 -1
- package/dist/lib/core/decorators/controller.js.map +1 -1
- package/dist/lib/core/decorators/index.d.ts +1 -0
- package/dist/lib/core/decorators/index.js +1 -0
- package/dist/lib/core/decorators/index.js.map +1 -1
- package/dist/lib/core/decorators/methods.js +4 -3
- package/dist/lib/core/decorators/methods.js.map +1 -1
- package/dist/lib/core/decorators/middleware.d.ts +40 -2
- package/dist/lib/core/decorators/middleware.js +54 -9
- package/dist/lib/core/decorators/middleware.js.map +1 -1
- package/dist/lib/core/decorators/service.d.ts +28 -0
- package/dist/lib/core/decorators/service.js +36 -0
- package/dist/lib/core/decorators/service.js.map +1 -0
- package/dist/lib/core/decorators/statusCode.js +3 -1
- package/dist/lib/core/decorators/statusCode.js.map +1 -1
- package/dist/lib/core/decorators/swagger.js +4 -3
- package/dist/lib/core/decorators/swagger.js.map +1 -1
- package/dist/lib/core/exception/index.d.ts +68 -0
- package/dist/lib/core/exception/index.js +123 -0
- package/dist/lib/core/exception/index.js.map +1 -0
- package/dist/lib/core/metadata/index.d.ts +6 -0
- package/dist/lib/core/metadata/index.js +13 -0
- package/dist/lib/core/metadata/index.js.map +1 -0
- package/dist/lib/core/package/index.d.ts +11 -0
- package/dist/lib/core/package/index.js +42 -0
- package/dist/lib/core/package/index.js.map +1 -0
- package/dist/lib/core/server/fast-router.d.ts +2 -2
- package/dist/lib/core/server/fast-router.js +17 -3
- package/dist/lib/core/server/fast-router.js.map +1 -1
- package/dist/lib/core/server/index.d.ts +32 -5
- package/dist/lib/core/server/index.js +188 -45
- package/dist/lib/core/server/index.js.map +1 -1
- package/dist/lib/core/server/parser-factory.js +59 -10
- package/dist/lib/core/server/parser-factory.js.map +1 -1
- package/dist/lib/core/server/response.js +21 -1
- package/dist/lib/core/server/response.js.map +1 -1
- package/dist/lib/core/types/index.d.ts +42 -29
- package/package.json +15 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Controller = void 0;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
4
5
|
/**
|
|
5
6
|
* Declares a class as a controller and assigns a base route path.
|
|
6
7
|
*
|
|
@@ -36,7 +37,7 @@ exports.Controller = void 0;
|
|
|
36
37
|
*/
|
|
37
38
|
const Controller = (path) => {
|
|
38
39
|
return (target) => {
|
|
39
|
-
return Reflect.defineMetadata(
|
|
40
|
+
return Reflect.defineMetadata(metadata_1.CONTROLLER_METADATA, path, target);
|
|
40
41
|
};
|
|
41
42
|
};
|
|
42
43
|
exports.Controller = Controller;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/controller.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAkB,EAAE;IAC/D,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,OAAO,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,0CAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAkB,EAAE;IAC/D,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,OAAO,OAAO,CAAC,cAAc,CAAC,8BAAmB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC,CAAA;AAJY,QAAA,UAAU,cAItB"}
|
|
@@ -23,4 +23,5 @@ __exportStar(require("./headers"), exports);
|
|
|
23
23
|
__exportStar(require("./statusCode"), exports);
|
|
24
24
|
__exportStar(require("./context"), exports);
|
|
25
25
|
__exportStar(require("./swagger"), exports);
|
|
26
|
+
__exportStar(require("./service"), exports);
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAAyB;AAEzB,4CAAyB;AACzB,4CAAyB;AACzB,+CAA4B;AAC5B,+CAA4B;AAC5B,4CAAyB;AACzB,+CAA4B;AAC5B,4CAAyB;AACzB,4CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAAyB;AAEzB,4CAAyB;AACzB,4CAAyB;AACzB,+CAA4B;AAC5B,+CAA4B;AAC5B,4CAAyB;AACzB,+CAA4B;AAC5B,4CAAyB;AACzB,4CAAyB;AACzB,4CAAyB"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Options = exports.Head = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
4
5
|
const methodDecorator = (method) => {
|
|
5
6
|
return (path) => {
|
|
6
7
|
return (target, propertyKey) => {
|
|
7
8
|
const controller = target.constructor;
|
|
8
|
-
const routers = Reflect.hasMetadata(
|
|
9
|
-
? Reflect.getMetadata(
|
|
9
|
+
const routers = Reflect.hasMetadata(metadata_1.ROUTE_METADATA, controller)
|
|
10
|
+
? Reflect.getMetadata(metadata_1.ROUTE_METADATA, controller)
|
|
10
11
|
: [];
|
|
11
12
|
routers.push({
|
|
12
13
|
method,
|
|
13
14
|
path,
|
|
14
15
|
handler: propertyKey,
|
|
15
16
|
});
|
|
16
|
-
Reflect.defineMetadata(
|
|
17
|
+
Reflect.defineMetadata(metadata_1.ROUTE_METADATA, routers, controller);
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/methods.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/methods.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAG7C,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,EAAE;IAC3C,OAAO,CAAC,IAAkB,EAAmB,EAAE;QAC7C,OAAO,CAAC,MAAU,EAAE,WAAe,EAAE,EAAE;YACrC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;YAEtC,MAAM,OAAO,GAAe,OAAO,CAAC,WAAW,CAAC,yBAAc,EAAE,UAAU,CAAC;gBACzE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,yBAAc,EAAE,UAAU,CAAC;gBACjD,CAAC,CAAC,EAAE,CAAC;YAEP,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM;gBACN,IAAI;gBACJ,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;YAEH,OAAO,CAAC,cAAc,CAAC,yBAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAC9D,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;GAUG;AACU,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACU,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACU,QAAA,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAE9C;;;;;;;;GAQG;AACU,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AAEhD;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACU,QAAA,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -33,7 +33,45 @@ import { T } from '../types';
|
|
|
33
33
|
* };
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
-
* @param {T.ContextHandler}
|
|
36
|
+
* @param {T.ContextHandler[]} middlewares - Middleware function to execute before the route handler.
|
|
37
37
|
* @returns {MethodDecorator}
|
|
38
38
|
*/
|
|
39
|
-
export declare const Middleware: (
|
|
39
|
+
export declare const Middleware: (...middlewares: (T.ContextHandler | T.ContextHandler[])[]) => MethodDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* Attaches a middleware function to a controller method.
|
|
42
|
+
*
|
|
43
|
+
* The middleware will be executed **before the route handler**.
|
|
44
|
+
* If the middleware calls `next(err)`, the error will be forwarded
|
|
45
|
+
* to the framework's error handler. Otherwise, the original
|
|
46
|
+
* controller method will be executed.
|
|
47
|
+
*
|
|
48
|
+
* This decorator also stores middleware metadata using `Reflect.defineMetadata`
|
|
49
|
+
* so the framework can discover and execute it during the request lifecycle.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* class UserController {
|
|
54
|
+
*
|
|
55
|
+
* \@UseGuards(authMiddleware)
|
|
56
|
+
* async profile(ctx: T.Context) {
|
|
57
|
+
* return { user: ctx.user };
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Example middleware:
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const authMiddleware: T.ContextHandler = (ctx, next) => {
|
|
67
|
+
* if (!ctx.user) {
|
|
68
|
+
* return next(new Error("Unauthorized"));
|
|
69
|
+
* }
|
|
70
|
+
* next();
|
|
71
|
+
* };
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @param {T.ContextHandler[]} middlewares - Middleware function to execute before the route handler.
|
|
75
|
+
* @returns {MethodDecorator}
|
|
76
|
+
*/
|
|
77
|
+
export declare const UseGuards: (...middlewares: (T.ContextHandler | T.ContextHandler[])[]) => MethodDecorator;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Middleware = void 0;
|
|
3
|
+
exports.UseGuards = exports.Middleware = void 0;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
4
5
|
/**
|
|
5
6
|
* Attaches a middleware function to a controller method.
|
|
6
7
|
*
|
|
@@ -35,21 +36,27 @@ exports.Middleware = void 0;
|
|
|
35
36
|
* };
|
|
36
37
|
* ```
|
|
37
38
|
*
|
|
38
|
-
* @param {T.ContextHandler}
|
|
39
|
+
* @param {T.ContextHandler[]} middlewares - Middleware function to execute before the route handler.
|
|
39
40
|
* @returns {MethodDecorator}
|
|
40
41
|
*/
|
|
41
|
-
const Middleware = (
|
|
42
|
-
return (target,
|
|
42
|
+
const Middleware = (...middlewares) => {
|
|
43
|
+
return (target, _, descriptor) => {
|
|
43
44
|
const originalMethod = descriptor.value;
|
|
44
45
|
descriptor.value = function (ctx, next) {
|
|
45
46
|
try {
|
|
46
|
-
Reflect.defineMetadata(
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
Reflect.defineMetadata(metadata_1.MIDDLEWARE_METADATA, descriptor, target);
|
|
48
|
+
let index = 0;
|
|
49
|
+
const nextMiddleware = (err) => {
|
|
50
|
+
if (err) {
|
|
49
51
|
return next(err);
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
const middleware = middlewares.flat()[index++];
|
|
54
|
+
if (!middleware) {
|
|
55
|
+
return originalMethod.call(this, ctx, next);
|
|
56
|
+
}
|
|
57
|
+
return middleware(ctx, nextMiddleware);
|
|
58
|
+
};
|
|
59
|
+
return nextMiddleware();
|
|
53
60
|
}
|
|
54
61
|
catch (error) {
|
|
55
62
|
return next(error);
|
|
@@ -58,4 +65,42 @@ const Middleware = (middleware) => {
|
|
|
58
65
|
};
|
|
59
66
|
};
|
|
60
67
|
exports.Middleware = Middleware;
|
|
68
|
+
/**
|
|
69
|
+
* Attaches a middleware function to a controller method.
|
|
70
|
+
*
|
|
71
|
+
* The middleware will be executed **before the route handler**.
|
|
72
|
+
* If the middleware calls `next(err)`, the error will be forwarded
|
|
73
|
+
* to the framework's error handler. Otherwise, the original
|
|
74
|
+
* controller method will be executed.
|
|
75
|
+
*
|
|
76
|
+
* This decorator also stores middleware metadata using `Reflect.defineMetadata`
|
|
77
|
+
* so the framework can discover and execute it during the request lifecycle.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* class UserController {
|
|
82
|
+
*
|
|
83
|
+
* \@UseGuards(authMiddleware)
|
|
84
|
+
* async profile(ctx: T.Context) {
|
|
85
|
+
* return { user: ctx.user };
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* Example middleware:
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* const authMiddleware: T.ContextHandler = (ctx, next) => {
|
|
95
|
+
* if (!ctx.user) {
|
|
96
|
+
* return next(new Error("Unauthorized"));
|
|
97
|
+
* }
|
|
98
|
+
* next();
|
|
99
|
+
* };
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @param {T.ContextHandler[]} middlewares - Middleware function to execute before the route handler.
|
|
103
|
+
* @returns {MethodDecorator}
|
|
104
|
+
*/
|
|
105
|
+
exports.UseGuards = exports.Middleware;
|
|
61
106
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/middleware.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/middleware.ts"],"names":[],"mappings":";;;AAAA,0CAAkD;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACI,MAAM,UAAU,GAAG,CAAC,GAAG,WAAsD,EAAmB,EAAE;IAEvG,OAAO,CAAC,MAAW,EAAE,CAAM,EAAE,UAA8B,EAAE,EAAE;QAC7D,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,UAAU,GAAc,EAAE,IAAoB;YAC/D,IAAI,CAAC;gBAEH,OAAO,CAAC,cAAc,CAAC,8BAAmB,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;gBAEhE,IAAI,KAAK,GAAG,CAAC,CAAC;gBAEd,MAAM,cAAc,GAAG,CAAC,GAAS,EAAO,EAAE;oBACxC,IAAI,GAAG,EAAE,CAAC;wBACR,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;oBACnB,CAAC;oBAED,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;oBAE/C,IAAI,CAAC,UAAU,EAAE,CAAC;wBAChB,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;oBAC9C,CAAC;oBAED,OAAO,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBACzC,CAAC,CAAC;gBAEF,OAAO,cAAc,EAAE,CAAC;YAE1B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBAEpB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,UAAU,cAkCrB;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACU,QAAA,SAAS,GAAG,kBAAU,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type ServiceClass = new () => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Registers service dependencies for a controller.
|
|
4
|
+
*
|
|
5
|
+
* The specified services will be available for dependency injection
|
|
6
|
+
* when the controller instance is created.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* \@Service([
|
|
11
|
+
* CatService,
|
|
12
|
+
* DogService
|
|
13
|
+
* ])
|
|
14
|
+
* \@Controller('/cats')
|
|
15
|
+
* class CatController {
|
|
16
|
+
*
|
|
17
|
+
* constructor(
|
|
18
|
+
* private dogService: DogService,
|
|
19
|
+
* private catService: CatService
|
|
20
|
+
* ) {}
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param services Array of service classes to register.
|
|
25
|
+
* @returns Class decorator.
|
|
26
|
+
*/
|
|
27
|
+
export declare const Service: (...services: (ServiceClass | ServiceClass[])[]) => ClassDecorator;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Service = void 0;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
5
|
+
/**
|
|
6
|
+
* Registers service dependencies for a controller.
|
|
7
|
+
*
|
|
8
|
+
* The specified services will be available for dependency injection
|
|
9
|
+
* when the controller instance is created.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* \@Service([
|
|
14
|
+
* CatService,
|
|
15
|
+
* DogService
|
|
16
|
+
* ])
|
|
17
|
+
* \@Controller('/cats')
|
|
18
|
+
* class CatController {
|
|
19
|
+
*
|
|
20
|
+
* constructor(
|
|
21
|
+
* private dogService: DogService,
|
|
22
|
+
* private catService: CatService
|
|
23
|
+
* ) {}
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param services Array of service classes to register.
|
|
28
|
+
* @returns Class decorator.
|
|
29
|
+
*/
|
|
30
|
+
const Service = (...services) => {
|
|
31
|
+
return (target) => {
|
|
32
|
+
Reflect.defineMetadata(metadata_1.SERVICE_METADATA, services.flat(), target);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.Service = Service;
|
|
36
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/service.ts"],"names":[],"mappings":";;;AAAA,0CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,OAAO,GAAG,CAAC,GAAG,QAA2C,EAAkB,EAAE;IACxF,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,OAAO,CAAC,cAAc,CAAC,2BAAgB,EAAC,QAAQ,CAAC,IAAI,EAAE,EAAC,MAAM,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC,CAAA;AAJY,QAAA,OAAO,WAInB"}
|
|
@@ -30,7 +30,9 @@ const StatusCode = (statusCode) => {
|
|
|
30
30
|
const originalMethod = descriptor.value;
|
|
31
31
|
const code = statusCode < 100 ? 100 : statusCode > 599 ? 599 : statusCode;
|
|
32
32
|
descriptor.value = async function (ctx, next) {
|
|
33
|
-
ctx.res.
|
|
33
|
+
if (!ctx.res.headersSent) {
|
|
34
|
+
ctx.res.writeHead(code, { 'Content-Type': 'application/json' });
|
|
35
|
+
}
|
|
34
36
|
return await originalMethod.call(this, ctx, next);
|
|
35
37
|
};
|
|
36
38
|
return descriptor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusCode.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/statusCode.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,UAAU,GAAG,CAAC,UAAwB,EAAmB,EAAE;IACpE,OAAO,CAAC,MAAW,EAAE,GAAQ,EAAE,UAA8B,EAAE,EAAE;QAC7D,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,MAAM,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;QAE1E,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACnE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"statusCode.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/statusCode.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,UAAU,GAAG,CAAC,UAAwB,EAAmB,EAAE;IACpE,OAAO,CAAC,MAAW,EAAE,GAAQ,EAAE,UAA8B,EAAE,EAAE;QAC7D,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,MAAM,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;QAE1E,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACnE,IAAG,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACtB,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACpE,CAAC;YACD,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC,CAAC;AAfW,QAAA,UAAU,cAerB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Swagger = void 0;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
4
5
|
/**
|
|
5
6
|
* Attaches Swagger/OpenAPI specification metadata to a controller method.
|
|
6
7
|
*
|
|
@@ -38,14 +39,14 @@ exports.Swagger = void 0;
|
|
|
38
39
|
const Swagger = (data = {}) => {
|
|
39
40
|
return (target, propertyKey) => {
|
|
40
41
|
const controller = target.constructor;
|
|
41
|
-
const swaggers = Reflect.hasMetadata(
|
|
42
|
-
? Reflect.getMetadata(
|
|
42
|
+
const swaggers = Reflect.hasMetadata(metadata_1.SWAGGER_METADATA, controller)
|
|
43
|
+
? Reflect.getMetadata(metadata_1.SWAGGER_METADATA, controller)
|
|
43
44
|
: [];
|
|
44
45
|
swaggers.push({
|
|
45
46
|
handler: propertyKey,
|
|
46
47
|
...data,
|
|
47
48
|
});
|
|
48
|
-
Reflect.defineMetadata(
|
|
49
|
+
Reflect.defineMetadata(metadata_1.SWAGGER_METADATA, swaggers, controller);
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
exports.Swagger = Swagger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/swagger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/swagger.ts"],"names":[],"mappings":";;;AAAA,0CAA+C;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,MAAM,OAAO,GAAG,CAAC,OAAuB,EAAE,EAAmB,EAAE;IACpE,OAAO,CAAC,MAAW,EAAE,WAAgB,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;QAEtC,MAAM,QAAQ,GAAU,OAAO,CAAC,WAAW,CAAC,2BAAgB,EAAE,UAAU,CAAC;YACvE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,2BAAgB,EAAE,UAAU,CAAC;YACnD,CAAC,CAAC,EAAE,CAAC;QAEP,QAAQ,CAAC,IAAI,CAAC;YACZ,OAAO,EAAE,WAAW;YACpB,GAAG,IAAI;SACR,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,2BAAgB,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACjE,CAAC,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare const HttpStatus: {
|
|
2
|
+
readonly BAD_REQUEST: 400;
|
|
3
|
+
readonly UNAUTHORIZED: 401;
|
|
4
|
+
readonly FORBIDDEN: 403;
|
|
5
|
+
readonly NOT_FOUND: 404;
|
|
6
|
+
readonly METHOD_NOT_ALLOWED: 405;
|
|
7
|
+
readonly CONFLICT: 409;
|
|
8
|
+
readonly GONE: 410;
|
|
9
|
+
readonly UNSUPPORTED_MEDIA_TYPE: 415;
|
|
10
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
11
|
+
readonly TOO_MANY_REQUESTS: 429;
|
|
12
|
+
readonly INTERNAL_SERVER_ERROR: 500;
|
|
13
|
+
readonly NOT_IMPLEMENTED: 501;
|
|
14
|
+
readonly BAD_GATEWAY: 502;
|
|
15
|
+
readonly SERVICE_UNAVAILABLE: 503;
|
|
16
|
+
readonly GATEWAY_TIMEOUT: 504;
|
|
17
|
+
};
|
|
18
|
+
declare class HttpException extends Error {
|
|
19
|
+
readonly statusCode: number;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
constructor(statusCode: number, message: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class BadRequestException extends HttpException {
|
|
24
|
+
constructor(message?: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class UnauthorizedException extends HttpException {
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class ForbiddenException extends HttpException {
|
|
30
|
+
constructor(message?: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class NotFoundException extends HttpException {
|
|
33
|
+
constructor(message?: string);
|
|
34
|
+
}
|
|
35
|
+
export declare class MethodNotAllowedException extends HttpException {
|
|
36
|
+
constructor(message?: string);
|
|
37
|
+
}
|
|
38
|
+
export declare class ConflictException extends HttpException {
|
|
39
|
+
constructor(message?: string);
|
|
40
|
+
}
|
|
41
|
+
export declare class GoneException extends HttpException {
|
|
42
|
+
constructor(message?: string);
|
|
43
|
+
}
|
|
44
|
+
export declare class UnsupportedMediaTypeException extends HttpException {
|
|
45
|
+
constructor(message?: string);
|
|
46
|
+
}
|
|
47
|
+
export declare class UnprocessableEntityException extends HttpException {
|
|
48
|
+
constructor(message?: string);
|
|
49
|
+
}
|
|
50
|
+
export declare class TooManyRequestsException extends HttpException {
|
|
51
|
+
constructor(message?: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class InternalServerErrorException extends HttpException {
|
|
54
|
+
constructor(message?: string);
|
|
55
|
+
}
|
|
56
|
+
export declare class NotImplementedException extends HttpException {
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
|
59
|
+
export declare class BadGatewayException extends HttpException {
|
|
60
|
+
constructor(message?: string);
|
|
61
|
+
}
|
|
62
|
+
export declare class ServiceUnavailableException extends HttpException {
|
|
63
|
+
constructor(message?: string);
|
|
64
|
+
}
|
|
65
|
+
export declare class GatewayTimeoutException extends HttpException {
|
|
66
|
+
constructor(message?: string);
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GatewayTimeoutException = exports.ServiceUnavailableException = exports.BadGatewayException = exports.NotImplementedException = exports.InternalServerErrorException = exports.TooManyRequestsException = exports.UnprocessableEntityException = exports.UnsupportedMediaTypeException = exports.GoneException = exports.ConflictException = exports.MethodNotAllowedException = exports.NotFoundException = exports.ForbiddenException = exports.UnauthorizedException = exports.BadRequestException = exports.HttpStatus = void 0;
|
|
4
|
+
exports.HttpStatus = {
|
|
5
|
+
BAD_REQUEST: 400,
|
|
6
|
+
UNAUTHORIZED: 401,
|
|
7
|
+
FORBIDDEN: 403,
|
|
8
|
+
NOT_FOUND: 404,
|
|
9
|
+
METHOD_NOT_ALLOWED: 405,
|
|
10
|
+
CONFLICT: 409,
|
|
11
|
+
GONE: 410,
|
|
12
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
13
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
14
|
+
TOO_MANY_REQUESTS: 429,
|
|
15
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
16
|
+
NOT_IMPLEMENTED: 501,
|
|
17
|
+
BAD_GATEWAY: 502,
|
|
18
|
+
SERVICE_UNAVAILABLE: 503,
|
|
19
|
+
GATEWAY_TIMEOUT: 504,
|
|
20
|
+
};
|
|
21
|
+
class HttpException extends Error {
|
|
22
|
+
statusCode;
|
|
23
|
+
message;
|
|
24
|
+
constructor(statusCode, message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.statusCode = statusCode;
|
|
27
|
+
this.message = message;
|
|
28
|
+
this.name = this.constructor.name;
|
|
29
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
30
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class BadRequestException extends HttpException {
|
|
34
|
+
constructor(message = 'Bad Request') {
|
|
35
|
+
super(exports.HttpStatus.BAD_REQUEST, message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BadRequestException = BadRequestException;
|
|
39
|
+
class UnauthorizedException extends HttpException {
|
|
40
|
+
constructor(message = 'Unauthorized') {
|
|
41
|
+
super(exports.HttpStatus.UNAUTHORIZED, message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.UnauthorizedException = UnauthorizedException;
|
|
45
|
+
class ForbiddenException extends HttpException {
|
|
46
|
+
constructor(message = 'Forbidden') {
|
|
47
|
+
super(exports.HttpStatus.FORBIDDEN, message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ForbiddenException = ForbiddenException;
|
|
51
|
+
class NotFoundException extends HttpException {
|
|
52
|
+
constructor(message = 'Not Found') {
|
|
53
|
+
super(exports.HttpStatus.NOT_FOUND, message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.NotFoundException = NotFoundException;
|
|
57
|
+
class MethodNotAllowedException extends HttpException {
|
|
58
|
+
constructor(message = 'Method Not Allowed') {
|
|
59
|
+
super(exports.HttpStatus.METHOD_NOT_ALLOWED, message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.MethodNotAllowedException = MethodNotAllowedException;
|
|
63
|
+
class ConflictException extends HttpException {
|
|
64
|
+
constructor(message = 'Conflict') {
|
|
65
|
+
super(exports.HttpStatus.CONFLICT, message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.ConflictException = ConflictException;
|
|
69
|
+
class GoneException extends HttpException {
|
|
70
|
+
constructor(message = 'Gone') {
|
|
71
|
+
super(exports.HttpStatus.GONE, message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GoneException = GoneException;
|
|
75
|
+
class UnsupportedMediaTypeException extends HttpException {
|
|
76
|
+
constructor(message = 'Unsupported Media Type') {
|
|
77
|
+
super(exports.HttpStatus.UNSUPPORTED_MEDIA_TYPE, message);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException;
|
|
81
|
+
class UnprocessableEntityException extends HttpException {
|
|
82
|
+
constructor(message = 'Unprocessable Entity') {
|
|
83
|
+
super(exports.HttpStatus.UNPROCESSABLE_ENTITY, message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.UnprocessableEntityException = UnprocessableEntityException;
|
|
87
|
+
class TooManyRequestsException extends HttpException {
|
|
88
|
+
constructor(message = 'Too Many Requests') {
|
|
89
|
+
super(exports.HttpStatus.TOO_MANY_REQUESTS, message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.TooManyRequestsException = TooManyRequestsException;
|
|
93
|
+
class InternalServerErrorException extends HttpException {
|
|
94
|
+
constructor(message = 'Internal Server Error') {
|
|
95
|
+
super(exports.HttpStatus.INTERNAL_SERVER_ERROR, message);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.InternalServerErrorException = InternalServerErrorException;
|
|
99
|
+
class NotImplementedException extends HttpException {
|
|
100
|
+
constructor(message = 'Not Implemented') {
|
|
101
|
+
super(exports.HttpStatus.NOT_IMPLEMENTED, message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.NotImplementedException = NotImplementedException;
|
|
105
|
+
class BadGatewayException extends HttpException {
|
|
106
|
+
constructor(message = 'Bad Gateway') {
|
|
107
|
+
super(exports.HttpStatus.BAD_GATEWAY, message);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.BadGatewayException = BadGatewayException;
|
|
111
|
+
class ServiceUnavailableException extends HttpException {
|
|
112
|
+
constructor(message = 'Service Unavailable') {
|
|
113
|
+
super(exports.HttpStatus.SERVICE_UNAVAILABLE, message);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.ServiceUnavailableException = ServiceUnavailableException;
|
|
117
|
+
class GatewayTimeoutException extends HttpException {
|
|
118
|
+
constructor(message = 'Gateway Timeout') {
|
|
119
|
+
super(exports.HttpStatus.GATEWAY_TIMEOUT, message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.GatewayTimeoutException = GatewayTimeoutException;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/exception/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const CONTROLLER_METADATA: unique symbol;
|
|
2
|
+
export declare const ROUTE_METADATA: unique symbol;
|
|
3
|
+
export declare const SERVICE_METADATA: unique symbol;
|
|
4
|
+
export declare const SWAGGER_METADATA: unique symbol;
|
|
5
|
+
export declare const MIDDLEWARE_METADATA: unique symbol;
|
|
6
|
+
export declare const PARAMTYPES_METADATA = "design:paramtypes";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PARAMTYPES_METADATA = exports.MIDDLEWARE_METADATA = exports.SWAGGER_METADATA = exports.SERVICE_METADATA = exports.ROUTE_METADATA = exports.CONTROLLER_METADATA = void 0;
|
|
4
|
+
exports.CONTROLLER_METADATA = Symbol("controllers");
|
|
5
|
+
exports.ROUTE_METADATA = Symbol("routes");
|
|
6
|
+
exports.SERVICE_METADATA = Symbol("services");
|
|
7
|
+
exports.SWAGGER_METADATA = Symbol("swaggers");
|
|
8
|
+
exports.MIDDLEWARE_METADATA = Symbol("middlewares");
|
|
9
|
+
// "design:paramtypes" is a metadata key automatically generated by TypeScript
|
|
10
|
+
// when the emitDecoratorMetadata compiler option is enabled.
|
|
11
|
+
// It stores the constructor parameter types of a class and can be accessed through the Reflect Metadata API.
|
|
12
|
+
exports.PARAMTYPES_METADATA = "design:paramtypes";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/metadata/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAC5C,QAAA,cAAc,GAAQ,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvC,QAAA,gBAAgB,GAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AACzC,QAAA,gBAAgB,GAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AACzC,QAAA,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzD,+EAA+E;AAC/E,8DAA8D;AAC9D,6GAA6G;AAChG,QAAA,mBAAmB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class Package {
|
|
2
|
+
static import(name: string): any;
|
|
3
|
+
static get classTransformer(): {
|
|
4
|
+
plainToInstance: <T>(cls: new (...args: any[]) => T, plain: object) => any;
|
|
5
|
+
};
|
|
6
|
+
static get classValidator(): {
|
|
7
|
+
validate: <T extends object>(dto: T) => Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { Package };
|
|
11
|
+
export default Package;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Package = void 0;
|
|
4
|
+
class Package {
|
|
5
|
+
static import(name) {
|
|
6
|
+
try {
|
|
7
|
+
return require(name);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
throw new Error(`The package '${name}' caused by '${err.message}'. Please try installing the package using : npm install ${name} --save`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
static get classTransformer() {
|
|
14
|
+
try {
|
|
15
|
+
const { plainToInstance } = require('class-transformer');
|
|
16
|
+
return {
|
|
17
|
+
plainToInstance: (cls, plain) => {
|
|
18
|
+
return plainToInstance(cls, plain);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new Error(`The package 'class-transformer' caused by '${err.message}'. Please try installing the package using : npm install class-transformer --save`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static get classValidator() {
|
|
27
|
+
try {
|
|
28
|
+
const { validate } = require('class-validator');
|
|
29
|
+
return {
|
|
30
|
+
validate: async (dto) => {
|
|
31
|
+
return await validate(dto);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new Error(`The package 'class-validator' caused by '${err.message}'. Please try installing the package using : npm install class-validator --save`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Package = Package;
|
|
41
|
+
exports.default = Package;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/package/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO;IACT,MAAM,CAAC,MAAM,CAAC,IAAa;QACvB,IAAI,CAAC;YACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;QACD,OAAO,GAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,gBAAgB,GAAG,CAAC,OAAO,4DAA4D,IAAI,SAAS,CAAC,CAAA;QAC7I,CAAC;IACL,CAAC;IAED,MAAM,KAAK,gBAAgB;QACvB,IAAI,CAAC;YAED,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;YAIzD,OAAO;gBACH,eAAe,EAAE,CAAI,GAAwB,EAAE,KAAa,EAAE,EAAE;oBAC5D,OAAO,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACvC,CAAC;aACJ,CAAA;QAEL,CAAC;QAAC,OAAO,GAAO,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,8CAA8C,GAAG,CAAC,OAAO,mFAAmF,CAAC,CAAA;QACjK,CAAC;IACL,CAAC;IAED,MAAM,KAAK,cAAc;QACrB,IAAI,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAEhD,OAAO;gBACH,QAAQ,EAAE,KAAK,EAAoB,GAAM,EAAE,EAAE;oBACzC,OAAO,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC/B,CAAC;aACJ,CAAA;QAEL,CAAC;QAAC,OAAO,GAAO,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,CAAC,OAAO,iFAAiF,CAAC,CAAA;QAC7J,CAAC;IACL,CAAC;CACJ;AAEQ,0BAAO;AAChB,kBAAe,OAAO,CAAA"}
|
|
@@ -113,8 +113,8 @@ export declare class FastRouter {
|
|
|
113
113
|
* It supports parameterized routes, static routes, and (optionally)
|
|
114
114
|
* wildcard matching depending on router implementation.
|
|
115
115
|
*
|
|
116
|
-
* @param req Incoming HTTP request object
|
|
117
|
-
* @param res Server response object used to send output
|
|
116
|
+
* @param {IncomingMessage} req Incoming HTTP request object
|
|
117
|
+
* @param {ServerResponse} res Server response object used to send output
|
|
118
118
|
*
|
|
119
119
|
* @returns void
|
|
120
120
|
*
|