damex 1.1.6 → 2.0.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 +52 -8
- package/index.js +373 -0
- package/package.json +9 -6
- package/.prettierrc +0 -5
- package/lib/classes/AppRouter.d.ts +0 -4
- package/lib/classes/AppRouter.js +0 -11
- package/lib/classes/Server.d.ts +0 -9
- package/lib/classes/Server.js +0 -36
- package/lib/classes/index.d.ts +0 -2
- package/lib/classes/index.js +0 -18
- package/lib/decorators/controller.decorator.d.ts +0 -1
- package/lib/decorators/controller.decorator.js +0 -21
- package/lib/decorators/global-middleware.decorator.d.ts +0 -2
- package/lib/decorators/global-middleware.decorator.js +0 -9
- package/lib/decorators/http-methods.decorator.d.ts +0 -5
- package/lib/decorators/http-methods.decorator.js +0 -17
- package/lib/decorators/index.d.ts +0 -4
- package/lib/decorators/index.js +0 -20
- package/lib/decorators/middleware.decorator.d.ts +0 -2
- package/lib/decorators/middleware.decorator.js +0 -9
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -20
- package/lib/types/enums/ControllerMethodsParams.d.ts +0 -6
- package/lib/types/enums/ControllerMethodsParams.js +0 -10
- package/lib/types/enums/HttpMethods.d.ts +0 -7
- package/lib/types/enums/HttpMethods.js +0 -11
- package/lib/types/enums/ServerConfigsParams.d.ts +0 -4
- package/lib/types/enums/ServerConfigsParams.js +0 -8
- package/lib/types/enums/index.d.ts +0 -3
- package/lib/types/enums/index.js +0 -19
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -17
- package/src/classes/AppRouter.ts +0 -9
- package/src/classes/Server.ts +0 -43
- package/src/classes/index.ts +0 -2
- package/src/decorators/controller.decorator.ts +0 -45
- package/src/decorators/global-middleware.decorator.ts +0 -12
- package/src/decorators/http-methods.decorator.ts +0 -26
- package/src/decorators/index.ts +0 -4
- package/src/decorators/middleware.decorator.ts +0 -13
- package/src/index.ts +0 -5
- package/src/types/enums/ControllerMethodsParams.ts +0 -6
- package/src/types/enums/HttpMethods.ts +0 -7
- package/src/types/enums/ServerConfigsParams.ts +0 -4
- package/src/types/enums/index.ts +0 -3
- package/src/types/index.ts +0 -1
- package/tsconfig.json +0 -17
package/package.json
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
{
|
2
2
|
"name": "damex",
|
3
|
-
"module": "./
|
4
|
-
"version": "
|
3
|
+
"module": "./index.js",
|
4
|
+
"version": "2.0.1",
|
5
5
|
"author": {
|
6
6
|
"email": "matusalem.dev@gmail.com",
|
7
7
|
"name": "Matusal3m",
|
8
8
|
"url": "https://github.com/matusal3m"
|
9
9
|
},
|
10
|
-
"main": "./
|
10
|
+
"main": "./index.js",
|
11
11
|
"exports": {
|
12
|
-
".": "./
|
12
|
+
".": "./index.js"
|
13
13
|
},
|
14
14
|
"scripts": {
|
15
|
-
"
|
15
|
+
"test": "jest",
|
16
|
+
"build": "node build.js"
|
16
17
|
},
|
17
18
|
"devDependencies": {
|
18
19
|
"@types/cors": "^2.8.17",
|
19
20
|
"@types/express": "^5.0.0",
|
20
|
-
"
|
21
|
+
"@types/jest": "^30.0.0",
|
22
|
+
"esbuild": "0.25.8",
|
23
|
+
"ts-jest": "^29.4.0"
|
21
24
|
},
|
22
25
|
"dependencies": {
|
23
26
|
"cors": "^2.8.5",
|
package/.prettierrc
DELETED
package/lib/classes/AppRouter.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.AppRouter = void 0;
|
4
|
-
const express_1 = require("express");
|
5
|
-
class AppRouter {
|
6
|
-
static get router() {
|
7
|
-
return AppRouter.instance;
|
8
|
-
}
|
9
|
-
}
|
10
|
-
exports.AppRouter = AppRouter;
|
11
|
-
AppRouter.instance = (0, express_1.Router)();
|
package/lib/classes/Server.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import { type RequestHandler } from 'express';
|
2
|
-
export declare class Server {
|
3
|
-
readonly controllers: any[];
|
4
|
-
private readonly app;
|
5
|
-
constructor(controllers: any[]);
|
6
|
-
start(port?: number): void;
|
7
|
-
use(...handlers: RequestHandler[]): void;
|
8
|
-
private setupControllers;
|
9
|
-
}
|
package/lib/classes/Server.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.Server = void 0;
|
7
|
-
const enums_1 = require("../types/enums");
|
8
|
-
const express_1 = __importDefault(require("express"));
|
9
|
-
class Server {
|
10
|
-
constructor(controllers) {
|
11
|
-
this.controllers = controllers;
|
12
|
-
this.app = (0, express_1.default)();
|
13
|
-
this.setupControllers();
|
14
|
-
}
|
15
|
-
start(port = 3000) {
|
16
|
-
this.app.listen(port, () => {
|
17
|
-
console.log(`Application running on port ${port} 🟢`);
|
18
|
-
});
|
19
|
-
}
|
20
|
-
use(...handlers) {
|
21
|
-
this.app.use(handlers);
|
22
|
-
}
|
23
|
-
setupControllers() {
|
24
|
-
this.app.use(express_1.default.json());
|
25
|
-
this.controllers.forEach((controller) => {
|
26
|
-
const router = Reflect.getOwnMetadata(enums_1.ServerConfigsParams.Router, controller);
|
27
|
-
const globalMiddleware = Reflect.getOwnMetadata(enums_1.ServerConfigsParams.GlobalMiddleware, controller);
|
28
|
-
if (globalMiddleware) {
|
29
|
-
this.app.use(router, globalMiddleware);
|
30
|
-
return;
|
31
|
-
}
|
32
|
-
this.app.use(router);
|
33
|
-
});
|
34
|
-
}
|
35
|
-
}
|
36
|
-
exports.Server = Server;
|
package/lib/classes/index.d.ts
DELETED
package/lib/classes/index.js
DELETED
@@ -1,18 +0,0 @@
|
|
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("./AppRouter"), exports);
|
18
|
-
__exportStar(require("./Server"), exports);
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function Controller(path: string): (target: any) => void;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Controller = Controller;
|
4
|
-
const AppRouter_1 = require("../classes/AppRouter");
|
5
|
-
const enums_1 = require("../types/enums");
|
6
|
-
const ServerConfigsParams_1 = require("../types/enums/ServerConfigsParams");
|
7
|
-
function Controller(path) {
|
8
|
-
const router = AppRouter_1.AppRouter.router;
|
9
|
-
return function (target) {
|
10
|
-
const { prototype } = Object.getOwnPropertyDescriptors(target);
|
11
|
-
const [, ..._actionsNames] = Object.getOwnPropertyNames(prototype.value);
|
12
|
-
_actionsNames.forEach((_actionName) => {
|
13
|
-
var _a, _b, _c;
|
14
|
-
const _method = (_a = Reflect.getOwnMetadata(_actionName, prototype.value, enums_1.ControllerMethodsParams.Method)) !== null && _a !== void 0 ? _a : '';
|
15
|
-
const _middlewares = (_b = Reflect.getOwnMetadata(_actionName, prototype.value, enums_1.ControllerMethodsParams.Middleware)) !== null && _b !== void 0 ? _b : [];
|
16
|
-
const _path = (_c = Reflect.getOwnMetadata(_actionName, prototype.value, enums_1.ControllerMethodsParams.Path)) !== null && _c !== void 0 ? _c : '';
|
17
|
-
router[_method](`${path}${_path}`, _middlewares, prototype.value[_actionName]);
|
18
|
-
});
|
19
|
-
Reflect.defineMetadata(ServerConfigsParams_1.ServerConfigsParams.Router, router, target);
|
20
|
-
};
|
21
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GlobalMiddleware = GlobalMiddleware;
|
4
|
-
const ServerConfigsParams_1 = require("../types/enums/ServerConfigsParams");
|
5
|
-
function GlobalMiddleware(handlers) {
|
6
|
-
return function (target) {
|
7
|
-
Reflect.defineMetadata(ServerConfigsParams_1.ServerConfigsParams.GlobalMiddleware, handlers, target);
|
8
|
-
};
|
9
|
-
}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
export declare const Get: (path?: string) => (target: any, propertyKey: string) => void;
|
2
|
-
export declare const Post: (path?: string) => (target: any, propertyKey: string) => void;
|
3
|
-
export declare const Put: (path?: string) => (target: any, propertyKey: string) => void;
|
4
|
-
export declare const Patch: (path?: string) => (target: any, propertyKey: string) => void;
|
5
|
-
export declare const Delete: (path?: string) => (target: any, propertyKey: string) => void;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0;
|
4
|
-
const enums_1 = require("../types/enums");
|
5
|
-
function createHttpMethod(method) {
|
6
|
-
return function (path) {
|
7
|
-
return function (target, propertyKey) {
|
8
|
-
Reflect.defineMetadata(propertyKey, method, target, enums_1.ControllerMethodsParams.Method);
|
9
|
-
Reflect.defineMetadata(propertyKey, path, target, enums_1.ControllerMethodsParams.Path);
|
10
|
-
};
|
11
|
-
};
|
12
|
-
}
|
13
|
-
exports.Get = createHttpMethod(enums_1.HttpMethods.Get);
|
14
|
-
exports.Post = createHttpMethod(enums_1.HttpMethods.Post);
|
15
|
-
exports.Put = createHttpMethod(enums_1.HttpMethods.Put);
|
16
|
-
exports.Patch = createHttpMethod(enums_1.HttpMethods.Patch);
|
17
|
-
exports.Delete = createHttpMethod(enums_1.HttpMethods.Delete);
|
package/lib/decorators/index.js
DELETED
@@ -1,20 +0,0 @@
|
|
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-methods.decorator"), exports);
|
18
|
-
__exportStar(require("./controller.decorator"), exports);
|
19
|
-
__exportStar(require("./middleware.decorator"), exports);
|
20
|
-
__exportStar(require("./global-middleware.decorator"), exports);
|
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Middleware = Middleware;
|
4
|
-
const enums_1 = require("../types/enums");
|
5
|
-
function Middleware(handlers) {
|
6
|
-
return function (target, propertyKey) {
|
7
|
-
Reflect.defineMetadata(propertyKey, handlers, target, enums_1.ControllerMethodsParams.Middleware);
|
8
|
-
};
|
9
|
-
}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
@@ -1,20 +0,0 @@
|
|
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
|
-
require("reflect-metadata");
|
18
|
-
__exportStar(require("./classes"), exports);
|
19
|
-
__exportStar(require("./decorators"), exports);
|
20
|
-
__exportStar(require("./types"), exports);
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ControllerMethodsParams = void 0;
|
4
|
-
var ControllerMethodsParams;
|
5
|
-
(function (ControllerMethodsParams) {
|
6
|
-
ControllerMethodsParams["Path"] = "path";
|
7
|
-
ControllerMethodsParams["Method"] = "method";
|
8
|
-
ControllerMethodsParams["Middleware"] = "middleware";
|
9
|
-
ControllerMethodsParams["Router"] = "router";
|
10
|
-
})(ControllerMethodsParams || (exports.ControllerMethodsParams = ControllerMethodsParams = {}));
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.HttpMethods = void 0;
|
4
|
-
var HttpMethods;
|
5
|
-
(function (HttpMethods) {
|
6
|
-
HttpMethods["Get"] = "get";
|
7
|
-
HttpMethods["Post"] = "post";
|
8
|
-
HttpMethods["Put"] = "put";
|
9
|
-
HttpMethods["Patch"] = "patch";
|
10
|
-
HttpMethods["Delete"] = "delete";
|
11
|
-
})(HttpMethods || (exports.HttpMethods = HttpMethods = {}));
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ServerConfigsParams = void 0;
|
4
|
-
var ServerConfigsParams;
|
5
|
-
(function (ServerConfigsParams) {
|
6
|
-
ServerConfigsParams["Router"] = "router";
|
7
|
-
ServerConfigsParams["GlobalMiddleware"] = "globalMiddleware";
|
8
|
-
})(ServerConfigsParams || (exports.ServerConfigsParams = ServerConfigsParams = {}));
|
package/lib/types/enums/index.js
DELETED
@@ -1,19 +0,0 @@
|
|
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("./ControllerMethodsParams"), exports);
|
18
|
-
__exportStar(require("./HttpMethods"), exports);
|
19
|
-
__exportStar(require("./ServerConfigsParams"), exports);
|
package/lib/types/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './enums';
|
package/lib/types/index.js
DELETED
@@ -1,17 +0,0 @@
|
|
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("./enums"), exports);
|
package/src/classes/AppRouter.ts
DELETED
package/src/classes/Server.ts
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
import { ServerConfigsParams } from '../types/enums';
|
2
|
-
import express, { type Application, type RequestHandler } from 'express';
|
3
|
-
|
4
|
-
export class Server {
|
5
|
-
private readonly app: Application = express();
|
6
|
-
|
7
|
-
constructor(readonly controllers: any[]) {
|
8
|
-
this.setupControllers();
|
9
|
-
}
|
10
|
-
|
11
|
-
start(port: number = 3000) {
|
12
|
-
this.app.listen(port, () => {
|
13
|
-
console.log(`Application running on port ${port} 🟢`);
|
14
|
-
});
|
15
|
-
}
|
16
|
-
|
17
|
-
use(...handlers: RequestHandler[]) {
|
18
|
-
this.app.use(handlers);
|
19
|
-
}
|
20
|
-
|
21
|
-
private setupControllers() {
|
22
|
-
this.app.use(express.json());
|
23
|
-
|
24
|
-
this.controllers.forEach((controller) => {
|
25
|
-
const router = Reflect.getOwnMetadata(
|
26
|
-
ServerConfigsParams.Router,
|
27
|
-
controller
|
28
|
-
);
|
29
|
-
|
30
|
-
const globalMiddleware = Reflect.getOwnMetadata(
|
31
|
-
ServerConfigsParams.GlobalMiddleware,
|
32
|
-
controller
|
33
|
-
);
|
34
|
-
|
35
|
-
if (globalMiddleware) {
|
36
|
-
this.app.use(router, globalMiddleware);
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
this.app.use(router);
|
41
|
-
});
|
42
|
-
}
|
43
|
-
}
|
package/src/classes/index.ts
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
import { AppRouter } from '../classes/AppRouter';
|
2
|
-
import { ControllerMethodsParams } from '../types/enums';
|
3
|
-
import { ServerConfigsParams } from '../types/enums/ServerConfigsParams';
|
4
|
-
|
5
|
-
export function Controller(path: string) {
|
6
|
-
const router: any = AppRouter.router;
|
7
|
-
|
8
|
-
return function (target: any) {
|
9
|
-
const { prototype } = Object.getOwnPropertyDescriptors(target);
|
10
|
-
const [, ..._actionsNames] = Object.getOwnPropertyNames(
|
11
|
-
prototype.value
|
12
|
-
);
|
13
|
-
|
14
|
-
_actionsNames.forEach((_actionName) => {
|
15
|
-
const _method =
|
16
|
-
Reflect.getOwnMetadata(
|
17
|
-
_actionName,
|
18
|
-
prototype.value,
|
19
|
-
ControllerMethodsParams.Method
|
20
|
-
) ?? '';
|
21
|
-
|
22
|
-
const _middlewares =
|
23
|
-
Reflect.getOwnMetadata(
|
24
|
-
_actionName,
|
25
|
-
prototype.value,
|
26
|
-
ControllerMethodsParams.Middleware
|
27
|
-
) ?? [];
|
28
|
-
|
29
|
-
const _path =
|
30
|
-
Reflect.getOwnMetadata(
|
31
|
-
_actionName,
|
32
|
-
prototype.value,
|
33
|
-
ControllerMethodsParams.Path
|
34
|
-
) ?? '';
|
35
|
-
|
36
|
-
router[_method](
|
37
|
-
`${path}${_path}`,
|
38
|
-
_middlewares,
|
39
|
-
prototype.value[_actionName]
|
40
|
-
);
|
41
|
-
});
|
42
|
-
|
43
|
-
Reflect.defineMetadata(ServerConfigsParams.Router, router, target);
|
44
|
-
};
|
45
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { ServerConfigsParams } from '../types/enums/ServerConfigsParams';
|
2
|
-
import type { RequestHandler } from 'express';
|
3
|
-
|
4
|
-
export function GlobalMiddleware(handlers: RequestHandler[]) {
|
5
|
-
return function (target: any) {
|
6
|
-
Reflect.defineMetadata(
|
7
|
-
ServerConfigsParams.GlobalMiddleware,
|
8
|
-
handlers,
|
9
|
-
target
|
10
|
-
);
|
11
|
-
};
|
12
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { ControllerMethodsParams, HttpMethods } from '../types/enums';
|
2
|
-
|
3
|
-
function createHttpMethod(method: HttpMethods) {
|
4
|
-
return function (path?: string) {
|
5
|
-
return function (target: any, propertyKey: string) {
|
6
|
-
Reflect.defineMetadata(
|
7
|
-
propertyKey,
|
8
|
-
method,
|
9
|
-
target,
|
10
|
-
ControllerMethodsParams.Method
|
11
|
-
);
|
12
|
-
Reflect.defineMetadata(
|
13
|
-
propertyKey,
|
14
|
-
path,
|
15
|
-
target,
|
16
|
-
ControllerMethodsParams.Path
|
17
|
-
);
|
18
|
-
};
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
export const Get = createHttpMethod(HttpMethods.Get);
|
23
|
-
export const Post = createHttpMethod(HttpMethods.Post);
|
24
|
-
export const Put = createHttpMethod(HttpMethods.Put);
|
25
|
-
export const Patch = createHttpMethod(HttpMethods.Patch);
|
26
|
-
export const Delete = createHttpMethod(HttpMethods.Delete);
|
package/src/decorators/index.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import { ControllerMethodsParams } from '../types/enums';
|
2
|
-
import type { RequestHandler } from 'express';
|
3
|
-
|
4
|
-
export function Middleware(handlers: RequestHandler[]) {
|
5
|
-
return function (target: any, propertyKey: string) {
|
6
|
-
Reflect.defineMetadata(
|
7
|
-
propertyKey,
|
8
|
-
handlers,
|
9
|
-
target,
|
10
|
-
ControllerMethodsParams.Middleware
|
11
|
-
);
|
12
|
-
};
|
13
|
-
}
|
package/src/index.ts
DELETED
package/src/types/enums/index.ts
DELETED
package/src/types/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './enums';
|
package/tsconfig.json
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "es2016",
|
4
|
-
"module": "commonjs",
|
5
|
-
"typeRoots": ["src/types/*", "node_modules/@types"],
|
6
|
-
"declaration": true,
|
7
|
-
"sourceMap": true,
|
8
|
-
"outDir": "lib",
|
9
|
-
"removeComments": true,
|
10
|
-
"esModuleInterop": true,
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
12
|
-
"strict": true,
|
13
|
-
"skipLibCheck": true,
|
14
|
-
"experimentalDecorators": true,
|
15
|
-
"emitDecoratorMetadata": true
|
16
|
-
}
|
17
|
-
}
|