@kawijsr/server-node 1.1.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/LICENSE +21 -0
- package/dist/commons/application.d.ts +16 -0
- package/dist/commons/application.js +41 -0
- package/dist/commons/application.js.map +1 -0
- package/dist/commons/configurations.d.ts +3 -0
- package/dist/commons/configurations.js +12 -0
- package/dist/commons/configurations.js.map +1 -0
- package/dist/commons/decorators/routes-register.d.ts +12 -0
- package/dist/commons/decorators/routes-register.js +114 -0
- package/dist/commons/decorators/routes-register.js.map +1 -0
- package/dist/commons/decorators/validator/match.decorator.d.ts +6 -0
- package/dist/commons/decorators/validator/match.decorator.js +38 -0
- package/dist/commons/decorators/validator/match.decorator.js.map +1 -0
- package/dist/commons/decorators/validator/validator.decorator.d.ts +3 -0
- package/dist/commons/decorators/validator/validator.decorator.js +29 -0
- package/dist/commons/decorators/validator/validator.decorator.js.map +1 -0
- package/dist/commons/dto/paginated.http.res.dto.d.ts +19 -0
- package/dist/commons/dto/paginated.http.res.dto.js +71 -0
- package/dist/commons/dto/paginated.http.res.dto.js.map +1 -0
- package/dist/commons/dto/query.http.req.dto.d.ts +11 -0
- package/dist/commons/dto/query.http.req.dto.js +82 -0
- package/dist/commons/dto/query.http.req.dto.js.map +1 -0
- package/dist/commons/exceptions/exceptions.d.ts +38 -0
- package/dist/commons/exceptions/exceptions.js +44 -0
- package/dist/commons/exceptions/exceptions.js.map +1 -0
- package/dist/commons/utils/class-extends.d.ts +5 -0
- package/dist/commons/utils/class-extends.js +21 -0
- package/dist/commons/utils/class-extends.js.map +1 -0
- package/dist/commons/utils/validator.d.ts +8 -0
- package/dist/commons/utils/validator.js +64 -0
- package/dist/commons/utils/validator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +7 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/commons/default.route.d.ts +3 -0
- package/dist/modules/commons/default.route.js +29 -0
- package/dist/modules/commons/default.route.js.map +1 -0
- package/dist/modules/health-check/health-check.commands.d.ts +11 -0
- package/dist/modules/health-check/health-check.commands.js +43 -0
- package/dist/modules/health-check/health-check.commands.js.map +1 -0
- package/dist/modules/health-check/health-check.routes.d.ts +16 -0
- package/dist/modules/health-check/health-check.routes.js +74 -0
- package/dist/modules/health-check/health-check.routes.js.map +1 -0
- package/dist/modules/health-check/health-check.service.d.ts +15 -0
- package/dist/modules/health-check/health-check.service.js +57 -0
- package/dist/modules/health-check/health-check.service.js.map +1 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +19 -0
- package/dist/routes.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kawijsr
|
|
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.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
export declare class Application {
|
|
3
|
+
private readonly port;
|
|
4
|
+
private readonly app;
|
|
5
|
+
private options;
|
|
6
|
+
constructor();
|
|
7
|
+
static build(options?: ApplicationOptions): Application;
|
|
8
|
+
use(middleware: any): this;
|
|
9
|
+
pipe(func: (self: Express) => void): this;
|
|
10
|
+
private router;
|
|
11
|
+
start(callback?: () => void): this;
|
|
12
|
+
}
|
|
13
|
+
interface ApplicationOptions {
|
|
14
|
+
routes: [any];
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Application = void 0;
|
|
4
|
+
const express = require("express");
|
|
5
|
+
const configurations_1 = require("./configurations");
|
|
6
|
+
class Application {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.port = configurations_1.Configurations.get('PORT') || 3000;
|
|
9
|
+
this.app = express();
|
|
10
|
+
}
|
|
11
|
+
static build(options) {
|
|
12
|
+
const newApp = new Application();
|
|
13
|
+
newApp.options = options || {};
|
|
14
|
+
return newApp;
|
|
15
|
+
}
|
|
16
|
+
use(middleware) {
|
|
17
|
+
this.app.use(middleware);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
pipe(func) {
|
|
21
|
+
typeof func === 'function' && func(this.app);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
router() {
|
|
25
|
+
if (!this.options.routes) {
|
|
26
|
+
console.warn('Routes not provided. Consider using Application.build({ routes: [Class] | require("path") })');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
Object.values(this.options.routes).forEach((route) => (new route()['instance'](this.app)));
|
|
30
|
+
}
|
|
31
|
+
start(callback) {
|
|
32
|
+
this.router();
|
|
33
|
+
this.app.listen(this.port, () => {
|
|
34
|
+
console.log(`Listening on port -> ${this.port}`);
|
|
35
|
+
callback && callback();
|
|
36
|
+
});
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Application = Application;
|
|
41
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../src/commons/application.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,qDAAkD;AAGlD,MAAa,WAAW;IAKtB;QAJiB,SAAI,GAAG,+BAAc,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;QAKzD,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAA4B;QACvC,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,CAAC,OAAO,GAAG,OAAO,IAAI,EAAwB,CAAC;QACrD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,GAAG,CAAC,UAAe;QACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAA6B;QAChC,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,8FAA8F,CAAC,CAAC;YAC7G,OAAO;QACT,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,QAAqB;QAEzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;YAC9B,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACjD,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA1CD,kCA0CC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Configurations = void 0;
|
|
4
|
+
const dotenv_1 = require("dotenv");
|
|
5
|
+
(0, dotenv_1.config)();
|
|
6
|
+
class Configurations {
|
|
7
|
+
static get(envVar) {
|
|
8
|
+
return process.env[envVar];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.Configurations = Configurations;
|
|
12
|
+
//# sourceMappingURL=configurations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurations.js","sourceRoot":"","sources":["../../src/commons/configurations.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,IAAA,eAAM,GAAE,CAAC;AAET,MAAa,cAAc;IACzB,MAAM,CAAC,GAAG,CAAC,MAAc;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF;AAJD,wCAIC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare function Routes(path: string): (target: any) => void;
|
|
3
|
+
export declare function Route(method: string, path: string, options?: RouteOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
4
|
+
export declare function Param(paramName: string): (target: Object, propertyKey: string, parameterIndex: number) => void;
|
|
5
|
+
export declare function Query(paramName: string): (target: Object, propertyKey: string, parameterIndex: number) => void;
|
|
6
|
+
export declare function Body(): (target: Object, propertyKey: string, parameterIndex: number) => void;
|
|
7
|
+
export declare function Req(): (target: Object, propertyKey: string, parameterIndex: number) => void;
|
|
8
|
+
export declare function Res(): (target: Object, propertyKey: string, parameterIndex: number) => void;
|
|
9
|
+
interface RouteOptions {
|
|
10
|
+
render?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Routes = Routes;
|
|
4
|
+
exports.Route = Route;
|
|
5
|
+
exports.Param = Param;
|
|
6
|
+
exports.Query = Query;
|
|
7
|
+
exports.Body = Body;
|
|
8
|
+
exports.Req = Req;
|
|
9
|
+
exports.Res = Res;
|
|
10
|
+
require("reflect-metadata");
|
|
11
|
+
const paramMetadataKey = Symbol('Param');
|
|
12
|
+
const queryMetadataKey = Symbol('Query');
|
|
13
|
+
const bodyMetadataKey = Symbol('Body');
|
|
14
|
+
const requestMetadataKey = Symbol('Request');
|
|
15
|
+
const responseMetadataKey = Symbol('Response');
|
|
16
|
+
function Routes(path) {
|
|
17
|
+
return function (target) {
|
|
18
|
+
const constructor = target.prototype.constructor;
|
|
19
|
+
constructor.path = path;
|
|
20
|
+
target.prototype.instance = (app) => {
|
|
21
|
+
const keys = Object.getOwnPropertyNames(target.prototype);
|
|
22
|
+
keys.forEach(key => {
|
|
23
|
+
if (key !== 'instance' && key !== 'constructor') {
|
|
24
|
+
const el = target.prototype[key];
|
|
25
|
+
if (el instanceof IRoute) {
|
|
26
|
+
const { method, path: routePath, handler } = el;
|
|
27
|
+
const mapped = `/${(path || '').replace('/', '')}${(routePath || '').replace('/', '')}`;
|
|
28
|
+
console.log(`Route -> ${method.toUpperCase()} ${mapped}`);
|
|
29
|
+
app[method.toLowerCase()](mapped, handler);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function Route(method, path, options) {
|
|
37
|
+
return function (target, propertyKey, descriptor) {
|
|
38
|
+
const func = descriptor.value;
|
|
39
|
+
const route = new IRoute();
|
|
40
|
+
route.method = method;
|
|
41
|
+
route.path = path;
|
|
42
|
+
route.handler = (req, res) => {
|
|
43
|
+
let params = Reflect.getOwnMetadata(paramMetadataKey, target, propertyKey) || [];
|
|
44
|
+
let query = Reflect.getOwnMetadata(queryMetadataKey, target, propertyKey) || [];
|
|
45
|
+
let body = Reflect.getOwnMetadata(bodyMetadataKey, target, propertyKey) || [];
|
|
46
|
+
let request = Reflect.getOwnMetadata(requestMetadataKey, target, propertyKey) || [];
|
|
47
|
+
let response = Reflect.getOwnMetadata(responseMetadataKey, target, propertyKey) || [];
|
|
48
|
+
const args = [...params, ...query, ...body, ...request, ...response].sort((a, b) => a.index - b.index)
|
|
49
|
+
.map(param => req.params[param.name] || req.query[param.name] || (param.name === '@@body@@' ? req.body : undefined) || (param.name === '@@request@@' ? req : undefined) || (param.name === '@@response@@' ? res : undefined));
|
|
50
|
+
if (options === null || options === void 0 ? void 0 : options.render) {
|
|
51
|
+
return func.apply(target, args);
|
|
52
|
+
}
|
|
53
|
+
const result = func.apply(target, args);
|
|
54
|
+
if (result instanceof Promise) {
|
|
55
|
+
return result.then(data => res.send(data)).catch(err => res.status(err.statusCode || 500).send(err));
|
|
56
|
+
}
|
|
57
|
+
return res.send(result);
|
|
58
|
+
};
|
|
59
|
+
descriptor.value = route;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function Param(paramName) {
|
|
63
|
+
return function (target, propertyKey, parameterIndex) {
|
|
64
|
+
let params = Reflect.getOwnMetadata(paramMetadataKey, target, propertyKey) || [];
|
|
65
|
+
params.push({
|
|
66
|
+
index: parameterIndex,
|
|
67
|
+
name: paramName
|
|
68
|
+
});
|
|
69
|
+
Reflect.defineMetadata(paramMetadataKey, params, target, propertyKey);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function Query(paramName) {
|
|
73
|
+
return function (target, propertyKey, parameterIndex) {
|
|
74
|
+
let query = Reflect.getOwnMetadata(queryMetadataKey, target, propertyKey) || [];
|
|
75
|
+
query.push({
|
|
76
|
+
index: parameterIndex,
|
|
77
|
+
name: paramName
|
|
78
|
+
});
|
|
79
|
+
Reflect.defineMetadata(queryMetadataKey, query, target, propertyKey);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function Body() {
|
|
83
|
+
return function (target, propertyKey, parameterIndex) {
|
|
84
|
+
let body = Reflect.getOwnMetadata(bodyMetadataKey, target, propertyKey) || [];
|
|
85
|
+
body.push({
|
|
86
|
+
index: parameterIndex,
|
|
87
|
+
name: '@@body@@'
|
|
88
|
+
});
|
|
89
|
+
Reflect.defineMetadata(bodyMetadataKey, body, target, propertyKey);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function Req() {
|
|
93
|
+
return function (target, propertyKey, parameterIndex) {
|
|
94
|
+
let request = Reflect.getOwnMetadata(requestMetadataKey, target, propertyKey) || [];
|
|
95
|
+
request.push({
|
|
96
|
+
index: parameterIndex,
|
|
97
|
+
name: '@@request@@'
|
|
98
|
+
});
|
|
99
|
+
Reflect.defineMetadata(requestMetadataKey, request, target, propertyKey);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function Res() {
|
|
103
|
+
return function (target, propertyKey, parameterIndex) {
|
|
104
|
+
let request = Reflect.getOwnMetadata(responseMetadataKey, target, propertyKey) || [];
|
|
105
|
+
request.push({
|
|
106
|
+
index: parameterIndex,
|
|
107
|
+
name: '@@response@@'
|
|
108
|
+
});
|
|
109
|
+
Reflect.defineMetadata(responseMetadataKey, request, target, propertyKey);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
class IRoute {
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=routes-register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-register.js","sourceRoot":"","sources":["../../../src/commons/decorators/routes-register.ts"],"names":[],"mappings":";;AASA,wBAoBC;AAED,sBAiCC;AAED,sBAYC;AAED,sBAYC;AAED,oBAYC;AAED,kBAYC;AAED,kBAYC;AAtID,4BAA0B;AAE1B,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AACzC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC7C,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAG/C,SAAgB,MAAM,CAAC,IAAY;IACjC,OAAO,UAAU,MAAW;QAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;QACjD,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC;QAExB,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,EAAE;YAClC,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC1D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACjB,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;oBAChD,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;oBACjC,IAAI,EAAE,YAAY,MAAM,EAAE,CAAC;wBACzB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;wBAChD,MAAM,MAA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K,EAAE,cAAc;YACrB,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,GAAG;IACjB,OAAO,UAAU,MAAc,EAAE,WAAmB,EAAE,cAAsB;QAC1E,IAAI,OAAO,GACP,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAE1E,OAAO,CAAC,IAAI,CAAC;YACX,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,aAAa;SACpB,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,GAAG;IACjB,OAAO,UAAU,MAAc,EAAE,WAAmB,EAAE,cAAsB;QAC1E,IAAI,OAAO,GACP,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAE3E,OAAO,CAAC,IAAI,CAAC;YACX,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM;CAIX"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions, ValidatorConstraintInterface, ValidationArguments } from 'class-validator';
|
|
2
|
+
export declare class MatchConstraint implements ValidatorConstraintInterface {
|
|
3
|
+
validate(value: any, args: ValidationArguments): boolean;
|
|
4
|
+
defaultMessage(args: ValidationArguments): string;
|
|
5
|
+
}
|
|
6
|
+
export declare function Match(property: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MatchConstraint = void 0;
|
|
10
|
+
exports.Match = Match;
|
|
11
|
+
const class_validator_1 = require("class-validator");
|
|
12
|
+
let MatchConstraint = class MatchConstraint {
|
|
13
|
+
validate(value, args) {
|
|
14
|
+
const [propertyName] = args.constraints;
|
|
15
|
+
const relatedValue = args.object[propertyName];
|
|
16
|
+
return value === relatedValue;
|
|
17
|
+
}
|
|
18
|
+
defaultMessage(args) {
|
|
19
|
+
const [propertyName] = args.constraints;
|
|
20
|
+
return `${args.property} must match ${propertyName}`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.MatchConstraint = MatchConstraint;
|
|
24
|
+
exports.MatchConstraint = MatchConstraint = __decorate([
|
|
25
|
+
(0, class_validator_1.ValidatorConstraint)({ name: 'Match' })
|
|
26
|
+
], MatchConstraint);
|
|
27
|
+
function Match(property, validationOptions) {
|
|
28
|
+
return (object, propertyName) => {
|
|
29
|
+
(0, class_validator_1.registerDecorator)({
|
|
30
|
+
target: object.constructor,
|
|
31
|
+
propertyName,
|
|
32
|
+
options: validationOptions,
|
|
33
|
+
constraints: [property],
|
|
34
|
+
validator: MatchConstraint,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=match.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.decorator.js","sourceRoot":"","sources":["../../../../src/commons/decorators/validator/match.decorator.ts"],"names":[],"mappings":";;;;;;;;;AAsBA,sBAUC;AAhCD,qDAMyB;AAGlB,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,QAAQ,CAAC,KAAU,EAAE,IAAyB;QAC5C,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QACxC,MAAM,YAAY,GAAI,IAAI,CAAC,MAAc,CAAC,YAAY,CAAC,CAAC;QACxD,OAAO,KAAK,KAAK,YAAY,CAAC;IAChC,CAAC;IAED,cAAc,CAAC,IAAyB;QACtC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QACxC,OAAO,GAAG,IAAI,CAAC,QAAQ,eAAe,YAAY,EAAE,CAAC;IACvD,CAAC;CACF,CAAA;AAXY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,qCAAmB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;GAC1B,eAAe,CAW3B;AAED,SAAgB,KAAK,CAAC,QAAgB,EAAE,iBAAqC;IAC3E,OAAO,CAAC,MAAW,EAAE,YAAoB,EAAE,EAAE;QAC3C,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY;YACZ,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,CAAC,QAAQ,CAAC;YACvB,SAAS,EAAE,eAAe;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Type = Type;
|
|
4
|
+
exports.Command = Command;
|
|
5
|
+
require("reflect-metadata");
|
|
6
|
+
const validator_1 = require("../../utils/validator");
|
|
7
|
+
const commandParamMetadataKey = Symbol('command:param');
|
|
8
|
+
function Type(ClassConstructor) {
|
|
9
|
+
return function (target, propertyKey, parameterIndex) {
|
|
10
|
+
const existingCommandParameters = Reflect.getOwnMetadata(commandParamMetadataKey, target, propertyKey) ||
|
|
11
|
+
[];
|
|
12
|
+
existingCommandParameters.push([parameterIndex, ClassConstructor]);
|
|
13
|
+
Reflect.defineMetadata(commandParamMetadataKey, existingCommandParameters, target, propertyKey);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function Command() {
|
|
17
|
+
return function (target, propertyName, descriptor) {
|
|
18
|
+
const method = descriptor.value;
|
|
19
|
+
descriptor.value = async function () {
|
|
20
|
+
const commandParameters = Reflect.getOwnMetadata(commandParamMetadataKey, target, propertyName);
|
|
21
|
+
await Promise.all((commandParameters === null || commandParameters === void 0 ? void 0 : commandParameters.map(async (commandParameter) => {
|
|
22
|
+
const [index, ClassConstructor] = commandParameter;
|
|
23
|
+
arguments[index] = await validator_1.Validator.validate(ClassConstructor, arguments[index]);
|
|
24
|
+
})) || []);
|
|
25
|
+
return method.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=validator.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.decorator.js","sourceRoot":"","sources":["../../../../src/commons/decorators/validator/validator.decorator.ts"],"names":[],"mappings":";;AAIA,oBAiBC;AAED,0BA0BC;AAjDD,4BAA0B;AAC1B,qDAAgD;AAChD,MAAM,uBAAuB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAExD,SAAgB,IAAI,CAAC,gBAAgB;IACnC,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,MAAM,yBAAyB,GAC7B,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,MAAM,EAAE,WAAW,CAAC;YACpE,EAAE,CAAC;QACL,yBAAyB,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACnE,OAAO,CAAC,cAAc,CACpB,uBAAuB,EACvB,yBAAyB,EACzB,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,OAAO;IACrB,OAAO,UACH,MAAW,EACX,YAAoB,EACpB,UAA8B;QAEhC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAM,CAAC;QAEjC,UAAU,CAAC,KAAK,GAAG,KAAK;YACtB,MAAM,iBAAiB,GAAkB,OAAO,CAAC,cAAc,CAC3D,uBAAuB,EACvB,MAAM,EACN,YAAY,CACf,CAAC;YACF,MAAM,OAAO,CAAC,GAAG,CACb,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE;gBAChD,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;gBACnD,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,qBAAS,CAAC,QAAQ,CACvC,gBAAgB,EAChB,SAAS,CAAC,KAAK,CAAC,CACnB,CAAC;YACJ,CAAC,CAAC,KAAI,EAAE,CACX,CAAC;YACF,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACvC,CAAC,CAAC;IACJ,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare class PaginatedDto {
|
|
2
|
+
total: number;
|
|
3
|
+
count: number;
|
|
4
|
+
per_page: number;
|
|
5
|
+
current_page: number;
|
|
6
|
+
total_pages: number;
|
|
7
|
+
}
|
|
8
|
+
declare class PaginatedLinksDto {
|
|
9
|
+
self: string;
|
|
10
|
+
next: string;
|
|
11
|
+
prev: string;
|
|
12
|
+
first: string;
|
|
13
|
+
last: string;
|
|
14
|
+
}
|
|
15
|
+
declare class PaginatedHttpResDto {
|
|
16
|
+
pagination: PaginatedDto;
|
|
17
|
+
links: PaginatedLinksDto;
|
|
18
|
+
}
|
|
19
|
+
export { PaginatedHttpResDto };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PaginatedHttpResDto = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
class PaginatedDto {
|
|
15
|
+
}
|
|
16
|
+
__decorate([
|
|
17
|
+
(0, class_transformer_1.Expose)(),
|
|
18
|
+
__metadata("design:type", Number)
|
|
19
|
+
], PaginatedDto.prototype, "total", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, class_transformer_1.Expose)(),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], PaginatedDto.prototype, "count", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, class_transformer_1.Expose)(),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], PaginatedDto.prototype, "per_page", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_transformer_1.Expose)(),
|
|
30
|
+
__metadata("design:type", Number)
|
|
31
|
+
], PaginatedDto.prototype, "current_page", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_transformer_1.Expose)(),
|
|
34
|
+
__metadata("design:type", Number)
|
|
35
|
+
], PaginatedDto.prototype, "total_pages", void 0);
|
|
36
|
+
class PaginatedLinksDto {
|
|
37
|
+
}
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_transformer_1.Expose)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], PaginatedLinksDto.prototype, "self", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_transformer_1.Expose)(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], PaginatedLinksDto.prototype, "next", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, class_transformer_1.Expose)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], PaginatedLinksDto.prototype, "prev", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, class_transformer_1.Expose)(),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], PaginatedLinksDto.prototype, "first", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, class_transformer_1.Expose)(),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], PaginatedLinksDto.prototype, "last", void 0);
|
|
58
|
+
class PaginatedHttpResDto {
|
|
59
|
+
}
|
|
60
|
+
exports.PaginatedHttpResDto = PaginatedHttpResDto;
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, class_transformer_1.Expose)(),
|
|
63
|
+
(0, class_transformer_1.Type)(() => PaginatedDto),
|
|
64
|
+
__metadata("design:type", PaginatedDto)
|
|
65
|
+
], PaginatedHttpResDto.prototype, "pagination", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, class_transformer_1.Expose)(),
|
|
68
|
+
(0, class_transformer_1.Type)(() => PaginatedLinksDto),
|
|
69
|
+
__metadata("design:type", PaginatedLinksDto)
|
|
70
|
+
], PaginatedHttpResDto.prototype, "links", void 0);
|
|
71
|
+
//# sourceMappingURL=paginated.http.res.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginated.http.res.dto.js","sourceRoot":"","sources":["../../../src/commons/dto/paginated.http.res.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAiD;AAEjD,MAAM,YAAY;CAejB;AAbC;IADC,IAAA,0BAAM,GAAE;;2CACM;AAGf;IADC,IAAA,0BAAM,GAAE;;2CACM;AAGf;IADC,IAAA,0BAAM,GAAE;;8CACS;AAGlB;IADC,IAAA,0BAAM,GAAE;;kDACa;AAGtB;IADC,IAAA,0BAAM,GAAE;;iDACY;AAGvB,MAAM,iBAAiB;CAetB;AAbC;IADC,IAAA,0BAAM,GAAE;;+CACK;AAGd;IADC,IAAA,0BAAM,GAAE;;+CACK;AAGd;IADC,IAAA,0BAAM,GAAE;;+CACK;AAGd;IADC,IAAA,0BAAM,GAAE;;gDACM;AAGf;IADC,IAAA,0BAAM,GAAE;;+CACK;AAGhB,MAAM,mBAAmB;CAQxB;AAEQ,kDAAmB;AAP1B;IAFC,IAAA,0BAAM,GAAE;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;8BACZ,YAAY;uDAAC;AAI1B;IAFC,IAAA,0BAAM,GAAE;IACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;8BACtB,iBAAiB;kDAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.QueryHttpReqDto = exports.QueryHttpReqEnum = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
var QueryHttpReqEnum;
|
|
16
|
+
(function (QueryHttpReqEnum) {
|
|
17
|
+
QueryHttpReqEnum[QueryHttpReqEnum["DEFAULT_PAGE"] = 1] = "DEFAULT_PAGE";
|
|
18
|
+
QueryHttpReqEnum[QueryHttpReqEnum["DEFAULT_PER_PAGE"] = 25] = "DEFAULT_PER_PAGE";
|
|
19
|
+
})(QueryHttpReqEnum || (exports.QueryHttpReqEnum = QueryHttpReqEnum = {}));
|
|
20
|
+
class QueryHttpReqDto {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.criteria = '';
|
|
23
|
+
this.page = QueryHttpReqEnum.DEFAULT_PAGE;
|
|
24
|
+
this.per_page = QueryHttpReqEnum.DEFAULT_PER_PAGE;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.QueryHttpReqDto = QueryHttpReqDto;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_transformer_1.Expose)(),
|
|
30
|
+
(0, class_validator_1.IsOptional)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], QueryHttpReqDto.prototype, "criteria", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_transformer_1.Expose)(),
|
|
35
|
+
(0, class_validator_1.IsDate)(),
|
|
36
|
+
(0, class_validator_1.IsOptional)(),
|
|
37
|
+
(0, class_transformer_1.Type)(() => Date),
|
|
38
|
+
(0, class_transformer_1.Transform)(({ obj, key }) => {
|
|
39
|
+
if (!obj[key]) {
|
|
40
|
+
return new Date(1800, 0, 1);
|
|
41
|
+
}
|
|
42
|
+
const dateStr = obj[key];
|
|
43
|
+
const [year, month, day] = dateStr.split('-').map(Number);
|
|
44
|
+
return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0));
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], QueryHttpReqDto.prototype, "from", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, class_transformer_1.Expose)(),
|
|
50
|
+
(0, class_validator_1.IsDate)(),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_transformer_1.Type)(() => Date),
|
|
53
|
+
(0, class_transformer_1.Transform)(({ obj, key }) => {
|
|
54
|
+
if (!obj[key]) {
|
|
55
|
+
return new Date(Date.UTC(3000, 0, 1, 23, 59, 59, 999));
|
|
56
|
+
}
|
|
57
|
+
const dateStr = obj[key];
|
|
58
|
+
const [year, month, day] = dateStr.split('-').map(Number);
|
|
59
|
+
return new Date(Date.UTC(year, month - 1, day, 23, 59, 59, 999));
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", Date)
|
|
62
|
+
], QueryHttpReqDto.prototype, "to", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, class_transformer_1.Expose)(),
|
|
65
|
+
(0, class_validator_1.IsOptional)(),
|
|
66
|
+
(0, class_validator_1.IsPositive)(),
|
|
67
|
+
(0, class_transformer_1.Transform)(({ value }) => {
|
|
68
|
+
return +(value || QueryHttpReqEnum.DEFAULT_PAGE);
|
|
69
|
+
}),
|
|
70
|
+
__metadata("design:type", Number)
|
|
71
|
+
], QueryHttpReqDto.prototype, "page", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, class_transformer_1.Expose)(),
|
|
74
|
+
(0, class_validator_1.IsOptional)(),
|
|
75
|
+
(0, class_validator_1.IsPositive)(),
|
|
76
|
+
(0, class_validator_1.Max)(255),
|
|
77
|
+
(0, class_transformer_1.Transform)(({ value }) => {
|
|
78
|
+
return +(value || QueryHttpReqEnum.DEFAULT_PER_PAGE);
|
|
79
|
+
}),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], QueryHttpReqDto.prototype, "per_page", void 0);
|
|
82
|
+
//# sourceMappingURL=query.http.req.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.http.req.dto.js","sourceRoot":"","sources":["../../../src/commons/dto/query.http.req.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsE;AACtE,yDAA4D;AAG5D,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uEAAgB,CAAA;IAChB,gFAAqB,CAAA;AACvB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,MAAa,eAAe;IAA5B;QAGE,aAAQ,GAAY,EAAE,CAAC;QAoCvB,SAAI,GAAY,gBAAgB,CAAC,YAAY,CAAC;QAS9C,aAAQ,GAAY,gBAAgB,CAAC,gBAAgB,CAAC;IACxD,CAAC;CAAA;AAjDD,0CAiDC;AA9CC;IAFC,IAAA,0BAAM,GAAE;IACR,IAAA,4BAAU,GAAE;;iDACU;AAcvB;IAZC,IAAA,0BAAM,GAAE;IACR,IAAA,wBAAM,GAAE;IACR,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAChB,IAAA,6BAAS,EAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAA8B,EAAE,EAAE;QACtD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACd,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,MAAM,OAAO,GAAW,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,EAAE,KAAK,EA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AAE,EAAE,EAAE;QACvB,OAAO,CAAC,CAAC,KAAK,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC,CAAC;;6CAC4C;AAS9C;IAPC,IAAA,0BAAM,GAAE;IACR,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAG,EAAC,GAAG,CAAC;IACR,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACvB,OAAO,CAAC,CAAC,KAAK,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvD,CAAC,CAAC;;iDACoD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare class HttpException extends Error {
|
|
2
|
+
readonly statusCode: number;
|
|
3
|
+
readonly details?: any;
|
|
4
|
+
constructor(message: string, statusCode: number, options?: {
|
|
5
|
+
cause?: any;
|
|
6
|
+
details?: any;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export declare class BadRequestException extends HttpException {
|
|
10
|
+
constructor(message?: string, options?: {
|
|
11
|
+
cause?: any;
|
|
12
|
+
details?: any;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export declare class UnauthorizedException extends HttpException {
|
|
16
|
+
constructor(message?: string, options?: {
|
|
17
|
+
cause?: any;
|
|
18
|
+
details?: any;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export declare class NotFoundException extends HttpException {
|
|
22
|
+
constructor(message?: string, options?: {
|
|
23
|
+
cause?: any;
|
|
24
|
+
details?: any;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export declare class UnprocessableEntityException extends HttpException {
|
|
28
|
+
constructor(message?: string, options?: {
|
|
29
|
+
cause?: any;
|
|
30
|
+
details?: any;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export declare class InternalServerErrorException extends HttpException {
|
|
34
|
+
constructor(message?: string, options?: {
|
|
35
|
+
cause?: any;
|
|
36
|
+
details?: any;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InternalServerErrorException = exports.UnprocessableEntityException = exports.NotFoundException = exports.UnauthorizedException = exports.BadRequestException = exports.HttpException = void 0;
|
|
4
|
+
class HttpException extends Error {
|
|
5
|
+
constructor(message, statusCode, options) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.statusCode = statusCode;
|
|
8
|
+
this.details = options === null || options === void 0 ? void 0 : options.details;
|
|
9
|
+
this.name = this.constructor.name;
|
|
10
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.HttpException = HttpException;
|
|
14
|
+
class BadRequestException extends HttpException {
|
|
15
|
+
constructor(message = 'Bad Request', options) {
|
|
16
|
+
super(message, 400, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BadRequestException = BadRequestException;
|
|
20
|
+
class UnauthorizedException extends HttpException {
|
|
21
|
+
constructor(message = 'Unauthorized', options) {
|
|
22
|
+
super(message, 401, options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.UnauthorizedException = UnauthorizedException;
|
|
26
|
+
class NotFoundException extends HttpException {
|
|
27
|
+
constructor(message = 'Not Found', options) {
|
|
28
|
+
super(message, 404, options);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.NotFoundException = NotFoundException;
|
|
32
|
+
class UnprocessableEntityException extends HttpException {
|
|
33
|
+
constructor(message = 'Unprocessable Entity', options) {
|
|
34
|
+
super(message, 422, options);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.UnprocessableEntityException = UnprocessableEntityException;
|
|
38
|
+
class InternalServerErrorException extends HttpException {
|
|
39
|
+
constructor(message = 'Internal Server Error', options) {
|
|
40
|
+
super(message, 500, options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.InternalServerErrorException = InternalServerErrorException;
|
|
44
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../../src/commons/exceptions/exceptions.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAItC,YACI,OAAe,EAAE,UAAkB,EACnC,OAAwC;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;CACF;AAbD,sCAaC;AAED,MAAa,mBAAoB,SAAQ,aAAa;IACpD,YACI,UAAkB,aAAa,EAC/B,OAAwC;QAC1C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AAND,kDAMC;AAED,MAAa,qBAAsB,SAAQ,aAAa;IACtD,YACI,UAAkB,cAAc,EAChC,OAAwC;QAC1C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AAND,sDAMC;AAED,MAAa,iBAAkB,SAAQ,aAAa;IAClD,YACI,UAAkB,WAAW,EAAE,OAAwC;QACzE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AALD,8CAKC;AAED,MAAa,4BAA6B,SAAQ,aAAa;IAC7D,YACI,UAAkB,sBAAsB,EACxC,OAAwC;QAC1C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;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