@lerianstudio/sindarian-server 1.0.0-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 +0 -0
- package/dist/constants/http-methods.d.ts +8 -0
- package/dist/constants/http-methods.d.ts.map +1 -0
- package/dist/constants/http-methods.js +12 -0
- package/dist/constants/http-methods.js.map +1 -0
- package/dist/constants/http-status.d.ts +57 -0
- package/dist/constants/http-status.d.ts.map +1 -0
- package/dist/constants/http-status.js +61 -0
- package/dist/constants/http-status.js.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +19 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/keys.d.ts +17 -0
- package/dist/constants/keys.d.ts.map +1 -0
- package/dist/constants/keys.js +20 -0
- package/dist/constants/keys.js.map +1 -0
- package/dist/controllers/base-controller.d.ts +5 -0
- package/dist/controllers/base-controller.d.ts.map +1 -0
- package/dist/controllers/base-controller.js +22 -0
- package/dist/controllers/base-controller.js.map +1 -0
- package/dist/controllers/decorators/body-decorator.d.ts +25 -0
- package/dist/controllers/decorators/body-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/body-decorator.js +65 -0
- package/dist/controllers/decorators/body-decorator.js.map +1 -0
- package/dist/controllers/decorators/controller-decorator.d.ts +18 -0
- package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/controller-decorator.js +89 -0
- package/dist/controllers/decorators/controller-decorator.js.map +1 -0
- package/dist/controllers/decorators/index.d.ts +7 -0
- package/dist/controllers/decorators/index.d.ts.map +1 -0
- package/dist/controllers/decorators/index.js +20 -0
- package/dist/controllers/decorators/index.js.map +1 -0
- package/dist/controllers/decorators/param-decorator.d.ts +21 -0
- package/dist/controllers/decorators/param-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/param-decorator.js +56 -0
- package/dist/controllers/decorators/param-decorator.js.map +1 -0
- package/dist/controllers/decorators/query-decorator.d.ts +26 -0
- package/dist/controllers/decorators/query-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/query-decorator.js +62 -0
- package/dist/controllers/decorators/query-decorator.js.map +1 -0
- package/dist/controllers/decorators/request-decorator.d.ts +24 -0
- package/dist/controllers/decorators/request-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/request-decorator.js +39 -0
- package/dist/controllers/decorators/request-decorator.js.map +1 -0
- package/dist/controllers/decorators/route-decorator.d.ts +43 -0
- package/dist/controllers/decorators/route-decorator.d.ts.map +1 -0
- package/dist/controllers/decorators/route-decorator.js +91 -0
- package/dist/controllers/decorators/route-decorator.js.map +1 -0
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +19 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/dependency-injection/container.d.ts +33 -0
- package/dist/dependency-injection/container.d.ts.map +1 -0
- package/dist/dependency-injection/container.js +59 -0
- package/dist/dependency-injection/container.js.map +1 -0
- package/dist/dependency-injection/index.d.ts +3 -0
- package/dist/dependency-injection/index.d.ts.map +1 -0
- package/dist/dependency-injection/index.js +22 -0
- package/dist/dependency-injection/index.js.map +1 -0
- package/dist/exceptions/api-exception.d.ts +38 -0
- package/dist/exceptions/api-exception.d.ts.map +1 -0
- package/dist/exceptions/api-exception.js +70 -0
- package/dist/exceptions/api-exception.js.map +1 -0
- package/dist/exceptions/http-exception.d.ts +16 -0
- package/dist/exceptions/http-exception.d.ts.map +1 -0
- package/dist/exceptions/http-exception.js +27 -0
- package/dist/exceptions/http-exception.js.map +1 -0
- package/dist/exceptions/index.d.ts +3 -0
- package/dist/exceptions/index.d.ts.map +1 -0
- package/dist/exceptions/index.js +19 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor/decorators/use-interceptor.d.ts +3 -0
- package/dist/interceptor/decorators/use-interceptor.d.ts.map +1 -0
- package/dist/interceptor/decorators/use-interceptor.js +9 -0
- package/dist/interceptor/decorators/use-interceptor.js.map +1 -0
- package/dist/interceptor/interceptor.d.ts +8 -0
- package/dist/interceptor/interceptor.d.ts.map +1 -0
- package/dist/interceptor/interceptor.js +7 -0
- package/dist/interceptor/interceptor.js.map +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/module-decorator.d.ts +22 -0
- package/dist/modules/module-decorator.d.ts.map +1 -0
- package/dist/modules/module-decorator.js +86 -0
- package/dist/modules/module-decorator.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +18 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/server-factory.d.ts +47 -0
- package/dist/server/server-factory.d.ts.map +1 -0
- package/dist/server/server-factory.js +131 -0
- package/dist/server/server-factory.js.map +1 -0
- package/dist/services/request.d.ts +7 -0
- package/dist/services/request.d.ts.map +1 -0
- package/dist/services/request.js +32 -0
- package/dist/services/request.js.map +1 -0
- package/dist/types/class.d.ts +4 -0
- package/dist/types/class.d.ts.map +1 -0
- package/dist/types/class.js +3 -0
- package/dist/types/class.js.map +1 -0
- package/dist/utils/apply-decorators.d.ts +13 -0
- package/dist/utils/apply-decorators.d.ts.map +1 -0
- package/dist/utils/apply-decorators.js +28 -0
- package/dist/utils/apply-decorators.js.map +1 -0
- package/dist/utils/class/get-class-methods.d.ts +7 -0
- package/dist/utils/class/get-class-methods.d.ts.map +1 -0
- package/dist/utils/class/get-class-methods.js +14 -0
- package/dist/utils/class/get-class-methods.js.map +1 -0
- package/dist/utils/nextjs/get-next-arguments.d.ts +3 -0
- package/dist/utils/nextjs/get-next-arguments.d.ts.map +1 -0
- package/dist/utils/nextjs/get-next-arguments.js +21 -0
- package/dist/utils/nextjs/get-next-arguments.js.map +1 -0
- package/dist/utils/url/index.d.ts +1 -0
- package/dist/utils/url/index.d.ts.map +1 -0
- package/dist/utils/url/index.js +2 -0
- package/dist/utils/url/index.js.map +1 -0
- package/dist/utils/url/url-join.d.ts +7 -0
- package/dist/utils/url/url-join.d.ts.map +1 -0
- package/dist/utils/url/url-join.js +17 -0
- package/dist/utils/url/url-join.js.map +1 -0
- package/dist/utils/url/url-match.d.ts +8 -0
- package/dist/utils/url/url-match.d.ts.map +1 -0
- package/dist/utils/url/url-match.js +15 -0
- package/dist/utils/url/url-match.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpException = void 0;
|
|
4
|
+
const http_status_1 = require("../constants/http-status");
|
|
5
|
+
/**
|
|
6
|
+
* Defines the base HTTP exception, which is handled by the default
|
|
7
|
+
* Exceptions Handler.
|
|
8
|
+
*
|
|
9
|
+
* Inspired by NestJS:
|
|
10
|
+
* https://github.com/nestjs/nest/blob/master/packages/common/exceptions/http.exception.ts
|
|
11
|
+
*/
|
|
12
|
+
class HttpException extends Error {
|
|
13
|
+
constructor(message, status) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.status = status || http_status_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
16
|
+
}
|
|
17
|
+
getStatus() {
|
|
18
|
+
return this.status;
|
|
19
|
+
}
|
|
20
|
+
getResponse() {
|
|
21
|
+
return {
|
|
22
|
+
message: this.message
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.HttpException = HttpException;
|
|
27
|
+
//# sourceMappingURL=http-exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.js","sourceRoot":"","sources":["../../src/exceptions/http-exception.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD;;;;;;GAMG;AACH,MAAa,aAAc,SAAQ,KAAK;IAGtC,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,wBAAU,CAAC,qBAAqB,CAAA;IAC1D,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,WAAW;QACT,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;CACF;AAjBD,sCAiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./http-exception"), exports);
|
|
18
|
+
__exportStar(require("./api-exception"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export * from './utils/apply-decorators';
|
|
3
|
+
export * from './exceptions';
|
|
4
|
+
export * from './controllers';
|
|
5
|
+
export * from './dependency-injection';
|
|
6
|
+
export * from './modules';
|
|
7
|
+
export * from './server';
|
|
8
|
+
export { REQUEST } from './services/request';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAA;AAEzB,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Central export file (barrel) for all plugin components.
|
|
3
|
+
// Ensure 'reflect-metadata' is loaded before any decorators are used.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.REQUEST = void 0;
|
|
20
|
+
require("reflect-metadata");
|
|
21
|
+
__exportStar(require("./utils/apply-decorators"), exports);
|
|
22
|
+
__exportStar(require("./exceptions"), exports);
|
|
23
|
+
__exportStar(require("./controllers"), exports);
|
|
24
|
+
__exportStar(require("./dependency-injection"), exports);
|
|
25
|
+
__exportStar(require("./modules"), exports);
|
|
26
|
+
__exportStar(require("./server"), exports);
|
|
27
|
+
// Services
|
|
28
|
+
var request_1 = require("./services/request");
|
|
29
|
+
Object.defineProperty(exports, "REQUEST", { enumerable: true, get: function () { return request_1.REQUEST; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,sEAAsE;;;;;;;;;;;;;;;;;AAEtE,4BAAyB;AAEzB,2DAAwC;AACxC,+CAA4B;AAC5B,gDAA6B;AAC7B,yDAAsC;AACtC,4CAAyB;AACzB,2CAAwB;AAExB,WAAW;AACX,8CAA4C;AAAnC,kGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interceptor.d.ts","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,wBAAgB,eAAe,CAAC,GAAG,YAAY,EAAE,WAAW,EAAE,IACpD,QAAQ,GAAG,EAAE,KAAK,MAAM,EAAE,YAAY,kBAAkB,UAGjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseInterceptors = UseInterceptors;
|
|
4
|
+
function UseInterceptors(...interceptors) {
|
|
5
|
+
return (target, key, descriptor) => {
|
|
6
|
+
Reflect.defineMetadata('interceptors', interceptors, descriptor.value);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=use-interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interceptor.js","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor.ts"],"names":[],"mappings":";;AAEA,0CAIC;AAJD,SAAgB,eAAe,CAAC,GAAG,YAA2B;IAC5D,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,UAA8B,EAAE,EAAE;QAClE,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../src/interceptor/interceptor.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CACvC,CAAA;AAED,8BAAsB,WAAW;IAC/B,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;CAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../src/interceptor/interceptor.ts"],"names":[],"mappings":";;;AAIA,MAAsB,WAAW;CAEhC;AAFD,kCAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./module-decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Class, Constructor } from '../types/class';
|
|
2
|
+
import { ControllerMetadata } from '../controllers/decorators/controller-decorator';
|
|
3
|
+
import { ResolutionContext } from 'inversify';
|
|
4
|
+
export type InjectionToken<T = any> = symbol | string | Constructor<T>;
|
|
5
|
+
type Provider = {
|
|
6
|
+
provide: InjectionToken;
|
|
7
|
+
useClass?: Class;
|
|
8
|
+
useValue?: any;
|
|
9
|
+
useFactory?: (context: ResolutionContext) => any | Promise<any>;
|
|
10
|
+
} | Class;
|
|
11
|
+
export type ModuleOptions = {
|
|
12
|
+
imports?: Class[];
|
|
13
|
+
controllers?: Class[];
|
|
14
|
+
providers?: Provider[];
|
|
15
|
+
};
|
|
16
|
+
export type ModuleMetadata = ControllerMetadata & {
|
|
17
|
+
controller: Class;
|
|
18
|
+
};
|
|
19
|
+
export declare function moduleHandler(target: Function, visited?: Set<Function>): ModuleMetadata[];
|
|
20
|
+
export declare function Module(options?: ModuleOptions): ClassDecorator;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=module-decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-decorator.d.ts","sourceRoot":"","sources":["../../src/modules/module-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AASlD,OAAO,EAEL,kBAAkB,EACnB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAG7C,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AAEtE,KAAK,QAAQ,GACT;IACE,OAAO,EAAE,cAAc,CAAA;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;CAChE,GACD,KAAK,CAAA;AAET,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,CAAC,EAAE,KAAK,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;IACrB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG;IAChD,UAAU,EAAE,KAAK,CAAA;CAClB,CAAA;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAE,GAAG,CAAC,QAAQ,CAAa,GAAG,cAAc,EAAE,CA6BpG;AAED,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CA2D9D"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moduleHandler = moduleHandler;
|
|
4
|
+
exports.Module = Module;
|
|
5
|
+
const container_1 = require("../dependency-injection/container");
|
|
6
|
+
const keys_1 = require("../constants/keys");
|
|
7
|
+
const controller_decorator_1 = require("../controllers/decorators/controller-decorator");
|
|
8
|
+
function moduleHandler(target, visited = new Set()) {
|
|
9
|
+
// Prevent infinite recursion by tracking visited modules
|
|
10
|
+
if (visited.has(target)) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
visited.add(target);
|
|
14
|
+
const routes = [];
|
|
15
|
+
const imports = target.prototype[keys_1.IMPORTS_PROPERTY];
|
|
16
|
+
const controllers = target.prototype[keys_1.CONTROLLERS_PROPERTY];
|
|
17
|
+
if (imports) {
|
|
18
|
+
for (const importEntity of imports) {
|
|
19
|
+
routes.push(...moduleHandler(importEntity, visited));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (controllers) {
|
|
23
|
+
for (const controller of controllers) {
|
|
24
|
+
const controllerRoutes = (0, controller_decorator_1.controllerHandler)(controller).map((route) => ({
|
|
25
|
+
...route,
|
|
26
|
+
controller
|
|
27
|
+
}));
|
|
28
|
+
routes.push(...controllerRoutes);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return routes;
|
|
32
|
+
}
|
|
33
|
+
function Module(options) {
|
|
34
|
+
const { imports, providers, controllers } = options || {};
|
|
35
|
+
const moduleContainer = new container_1.ContainerModule((container) => {
|
|
36
|
+
if (imports) {
|
|
37
|
+
imports.forEach((importEntity) => {
|
|
38
|
+
if (importEntity.prototype[keys_1.MODULE_PROPERTY]) {
|
|
39
|
+
container.load(importEntity.prototype[keys_1.MODULE_PROPERTY]);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (providers) {
|
|
44
|
+
providers.forEach((providerEntity) => {
|
|
45
|
+
if (typeof providerEntity === 'object') {
|
|
46
|
+
if (providerEntity.useClass) {
|
|
47
|
+
container.bind(providerEntity.provide).to(providerEntity.useClass);
|
|
48
|
+
}
|
|
49
|
+
else if (providerEntity.useFactory) {
|
|
50
|
+
container
|
|
51
|
+
.bind(providerEntity.provide)
|
|
52
|
+
.toDynamicValue(async (context) => {
|
|
53
|
+
return await providerEntity.useFactory(context);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (providerEntity.useValue) {
|
|
57
|
+
container
|
|
58
|
+
.bind(providerEntity.provide)
|
|
59
|
+
.toConstantValue(providerEntity.useValue);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
container.bind(providerEntity).to(providerEntity);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (controllers) {
|
|
68
|
+
controllers.forEach((controller) => {
|
|
69
|
+
container.bind(controller).to(controller);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return function (target) {
|
|
74
|
+
Reflect.defineMetadata(keys_1.MODULE_KEY, {
|
|
75
|
+
imports,
|
|
76
|
+
providers,
|
|
77
|
+
controllers
|
|
78
|
+
}, target);
|
|
79
|
+
const prototype = target.prototype;
|
|
80
|
+
prototype[keys_1.IMPORTS_PROPERTY] = imports;
|
|
81
|
+
prototype[keys_1.MODULE_PROPERTY] = moduleContainer;
|
|
82
|
+
prototype[keys_1.PROVIDERS_PROPERTY] = providers;
|
|
83
|
+
prototype[keys_1.CONTROLLERS_PROPERTY] = controllers;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=module-decorator.js.map
|
|
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,CAAC;YAChB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAA;YAC3C,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,MAAgB;QAC/B,OAAO,CAAC,cAAc,CACpB,iBAAU,EACV;YACE,OAAO;YACP,SAAS;YACT,WAAW;SACZ,EACD,MAAM,CACP,CAAA;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAElC,SAAS,CAAC,uBAAgB,CAAC,GAAG,OAAO,CAAA;QACrC,SAAS,CAAC,sBAAe,CAAC,GAAG,eAAe,CAAA;QAC5C,SAAS,CAAC,yBAAkB,CAAC,GAAG,SAAS,CAAA;QACzC,SAAS,CAAC,2BAAoB,CAAC,GAAG,WAAW,CAAA;IAC/C,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./server-factory"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Container } from '../dependency-injection/container';
|
|
2
|
+
import { ModuleMetadata } from '../modules/module-decorator';
|
|
3
|
+
import { Class } from '../types/class';
|
|
4
|
+
import { NextRequest } from 'next/server';
|
|
5
|
+
export declare class ServerFactory {
|
|
6
|
+
private globalPrefix;
|
|
7
|
+
private readonly module;
|
|
8
|
+
private readonly container;
|
|
9
|
+
private readonly routes;
|
|
10
|
+
constructor(module: Class, container: Container, routes: ModuleMetadata[]);
|
|
11
|
+
static create(module: Class): ServerFactory;
|
|
12
|
+
/**
|
|
13
|
+
* Set the global prefix for the server
|
|
14
|
+
* @param prefix - The global prefix to set
|
|
15
|
+
*/
|
|
16
|
+
setGlobalPrefix(prefix: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Handle a request
|
|
19
|
+
* @param request - The request to handle
|
|
20
|
+
* @param params - The parameters to pass to the handler
|
|
21
|
+
* @returns The response from the handler
|
|
22
|
+
*/
|
|
23
|
+
handler(request: NextRequest, { params }: {
|
|
24
|
+
params: Promise<any>;
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Parse the request
|
|
28
|
+
* @param request - The request to parse
|
|
29
|
+
* @returns The parsed request
|
|
30
|
+
*/
|
|
31
|
+
private _parseRequest;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch the route
|
|
34
|
+
* @param pathname - The pathname to fetch the route for
|
|
35
|
+
* @param method - The method to fetch the route for
|
|
36
|
+
* @returns The route
|
|
37
|
+
*/
|
|
38
|
+
private _fetchRoute;
|
|
39
|
+
/**
|
|
40
|
+
* Extract parameters from the URL using the route pattern
|
|
41
|
+
* @param pathname - The actual pathname
|
|
42
|
+
* @param routePattern - The route pattern with :param syntax
|
|
43
|
+
* @returns The extracted parameters
|
|
44
|
+
*/
|
|
45
|
+
private _extractParams;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=server-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-factory.d.ts","sourceRoot":"","sources":["../../src/server/server-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAiB,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE1E,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAEvD,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAa;IAEjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAE7B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE;WAM3D,MAAM,CAAC,MAAM,EAAE,KAAK;IAUlC;;;OAGG;IACI,eAAe,CAAC,MAAM,EAAE,MAAM;IAIrC;;;;;OAKG;IACU,OAAO,CAClB,OAAO,EAAE,WAAW,EACpB,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE;IA0EtC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAUrB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAgBnB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAqBvB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerFactory = void 0;
|
|
4
|
+
const keys_1 = require("../constants/keys");
|
|
5
|
+
const container_1 = require("../dependency-injection/container");
|
|
6
|
+
const module_decorator_1 = require("../modules/module-decorator");
|
|
7
|
+
const request_1 = require("../services/request");
|
|
8
|
+
const url_match_1 = require("../utils/url/url-match");
|
|
9
|
+
const server_1 = require("next/server");
|
|
10
|
+
class ServerFactory {
|
|
11
|
+
constructor(module, container, routes) {
|
|
12
|
+
this.globalPrefix = '';
|
|
13
|
+
this.module = module;
|
|
14
|
+
this.container = container;
|
|
15
|
+
this.routes = routes;
|
|
16
|
+
}
|
|
17
|
+
static create(module) {
|
|
18
|
+
const container = new container_1.Container();
|
|
19
|
+
container.load(module.prototype[keys_1.MODULE_PROPERTY]);
|
|
20
|
+
const routes = (0, module_decorator_1.moduleHandler)(module);
|
|
21
|
+
return new ServerFactory(module, container, routes);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Set the global prefix for the server
|
|
25
|
+
* @param prefix - The global prefix to set
|
|
26
|
+
*/
|
|
27
|
+
setGlobalPrefix(prefix) {
|
|
28
|
+
this.globalPrefix = prefix;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Handle a request
|
|
32
|
+
* @param request - The request to handle
|
|
33
|
+
* @param params - The parameters to pass to the handler
|
|
34
|
+
* @returns The response from the handler
|
|
35
|
+
*/
|
|
36
|
+
async handler(request, { params }) {
|
|
37
|
+
try {
|
|
38
|
+
// Bind the current request to the container for this request lifecycle
|
|
39
|
+
(0, request_1.bindRequest)(this.container, request);
|
|
40
|
+
const { pathname, method } = this._parseRequest(request);
|
|
41
|
+
const routeMatch = this._fetchRoute(pathname, method);
|
|
42
|
+
// Extract URL parameters from the matched route
|
|
43
|
+
const extractedParams = this._extractParams(pathname, routeMatch.path);
|
|
44
|
+
// Merge with any existing params
|
|
45
|
+
const resolvedParams = await params;
|
|
46
|
+
const combinedParams = { ...resolvedParams, ...extractedParams };
|
|
47
|
+
const controller = await this.container.getAsync(routeMatch?.controller);
|
|
48
|
+
if (!controller) {
|
|
49
|
+
return server_1.NextResponse.json({ message: 'Controller not found' }, { status: 500 });
|
|
50
|
+
}
|
|
51
|
+
const handler = controller[routeMatch?.methodName];
|
|
52
|
+
if (!handler) {
|
|
53
|
+
return server_1.NextResponse.json({ message: 'Method not found' }, { status: 500 });
|
|
54
|
+
}
|
|
55
|
+
return await handler.call(controller, request, {
|
|
56
|
+
params: Promise.resolve(combinedParams)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
// Handle route not found errors
|
|
61
|
+
if (error.message &&
|
|
62
|
+
error.message.includes('Route') &&
|
|
63
|
+
error.message.includes('not found')) {
|
|
64
|
+
return server_1.NextResponse.json({ message: 'Route not found' }, { status: 404 });
|
|
65
|
+
}
|
|
66
|
+
// Handle validation errors
|
|
67
|
+
if (error.message &&
|
|
68
|
+
(error.message.includes('Invalid param') ||
|
|
69
|
+
error.message.includes('Invalid body') ||
|
|
70
|
+
error.message.includes('Invalid query'))) {
|
|
71
|
+
return server_1.NextResponse.json({ message: error.message }, { status: 400 });
|
|
72
|
+
}
|
|
73
|
+
// Handle other errors
|
|
74
|
+
console.error('Server error:', error);
|
|
75
|
+
return server_1.NextResponse.json({ message: 'Internal server error' }, { status: 500 });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse the request
|
|
80
|
+
* @param request - The request to parse
|
|
81
|
+
* @returns The parsed request
|
|
82
|
+
*/
|
|
83
|
+
_parseRequest(request) {
|
|
84
|
+
const { pathname } = new URL(request.url);
|
|
85
|
+
const strippedPathname = pathname.replace(this.globalPrefix, '');
|
|
86
|
+
return {
|
|
87
|
+
pathname: strippedPathname,
|
|
88
|
+
method: request.method.toUpperCase()
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Fetch the route
|
|
93
|
+
* @param pathname - The pathname to fetch the route for
|
|
94
|
+
* @param method - The method to fetch the route for
|
|
95
|
+
* @returns The route
|
|
96
|
+
*/
|
|
97
|
+
_fetchRoute(pathname, method) {
|
|
98
|
+
const route = this.routes.find((route) => {
|
|
99
|
+
const match = (0, url_match_1.urlMatch)(pathname, route.path);
|
|
100
|
+
if (match && route.method === method) {
|
|
101
|
+
return route;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (!route) {
|
|
105
|
+
throw new Error(`Server: Route ${pathname} not found`);
|
|
106
|
+
}
|
|
107
|
+
return route;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Extract parameters from the URL using the route pattern
|
|
111
|
+
* @param pathname - The actual pathname
|
|
112
|
+
* @param routePattern - The route pattern with :param syntax
|
|
113
|
+
* @returns The extracted parameters
|
|
114
|
+
*/
|
|
115
|
+
_extractParams(pathname, routePattern) {
|
|
116
|
+
const pathSegments = pathname.split('/').filter(Boolean);
|
|
117
|
+
const patternSegments = routePattern.split('/').filter(Boolean);
|
|
118
|
+
const params = {};
|
|
119
|
+
for (let i = 0; i < patternSegments.length; i++) {
|
|
120
|
+
const patternSegment = patternSegments[i];
|
|
121
|
+
const pathSegment = pathSegments[i];
|
|
122
|
+
if (patternSegment.startsWith(':')) {
|
|
123
|
+
const paramName = patternSegment.substring(1);
|
|
124
|
+
params[paramName] = pathSegment;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return params;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.ServerFactory = ServerFactory;
|
|
131
|
+
//# sourceMappingURL=server-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-factory.js","sourceRoot":"","sources":["../../src/server/server-factory.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAElD,gEAA4D;AAC5D,iEAA0E;AAC1E,gDAA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gB,EAChB,YAAoB;QAEpB,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACxD,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAE/D,MAAM,MAAM,GAA8B,EAAE,CAAA;QAE5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,MAAM,cAAc,GAAG,eAAe,CAAC,CAAC,CAAC,CAAA;YACzC,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;YAEnC,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;gBAC7C,MAAM,CAAC,SAAS,CAAC,GAAG,WAAW,CAAA;YACjC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAjLD,sCAiLC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Container } from '../dependency-injection/container';
|
|
2
|
+
import { NextRequest } from 'next/server';
|
|
3
|
+
export declare const REQUEST: unique symbol;
|
|
4
|
+
export declare function bindRequest(container: Container, request: NextRequest): void;
|
|
5
|
+
export declare function getRequest(container?: Container): NextRequest;
|
|
6
|
+
export declare function getCurrentRequest(): NextRequest | null;
|
|
7
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/services/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,eAAO,MAAM,OAAO,eAAoB,CAAA;AAKxC,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,QAWrE;AAED,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,WAAW,CAY7D;AAED,wBAAgB,iBAAiB,IAAI,WAAW,GAAG,IAAI,CAEtD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REQUEST = void 0;
|
|
4
|
+
exports.bindRequest = bindRequest;
|
|
5
|
+
exports.getRequest = getRequest;
|
|
6
|
+
exports.getCurrentRequest = getCurrentRequest;
|
|
7
|
+
exports.REQUEST = Symbol('REQUEST');
|
|
8
|
+
// Global reference to the current request (for the current request lifecycle)
|
|
9
|
+
let currentRequest = null;
|
|
10
|
+
function bindRequest(container, request) {
|
|
11
|
+
// Store the current request globally for this request lifecycle
|
|
12
|
+
currentRequest = request;
|
|
13
|
+
// Check if REQUEST is already bound and rebind it
|
|
14
|
+
if (container.isBound(exports.REQUEST)) {
|
|
15
|
+
container.unbind(exports.REQUEST);
|
|
16
|
+
}
|
|
17
|
+
// Bind the current request as a constant value
|
|
18
|
+
container.bind(exports.REQUEST).toConstantValue(request);
|
|
19
|
+
}
|
|
20
|
+
function getRequest(container) {
|
|
21
|
+
if (container && container.isBound(exports.REQUEST)) {
|
|
22
|
+
return container.get(exports.REQUEST);
|
|
23
|
+
}
|
|
24
|
+
if (currentRequest) {
|
|
25
|
+
return currentRequest;
|
|
26
|
+
}
|
|
27
|
+
throw new Error('Request is not available. Make sure bindRequest is called before accessing the request.');
|
|
28
|
+
}
|
|
29
|
+
function getCurrentRequest() {
|
|
30
|
+
return currentRequest;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/services/request.ts"],"names":[],"mappings":";;;A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CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/types/class.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function that returns a new decorator that applies all decorators provided by param
|
|
3
|
+
*
|
|
4
|
+
* Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
|
|
5
|
+
*
|
|
6
|
+
* From: https://github.com/nestjs/nest/blob/master/packages/common/decorators/apply-decorators.d.ts
|
|
7
|
+
*
|
|
8
|
+
* @param decorators one or more decorators (e.g., `ApplyGuard(...)`)
|
|
9
|
+
*
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
13
|
+
//# sourceMappingURL=apply-decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-decorators.d.ts","sourceRoot":"","sources":["../../src/utils/apply-decorators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,GAAG,UAAU,EAAE,KAAK,CAAC,cAAc,GAAG,eAAe,GAAG,iBAAiB,CAAC,IAElE,SAAS,SAAS,QAAQ,EAAE,CAAC,EACnC,QAAQ,SAAS,GAAG,MAAM,EAC1B,cAAc,MAAM,GAAG,MAAM,EAC7B,aAAa,uBAAuB,CAAC,CAAC,CAAC,UAc1C"}
|