c2-http 1.0.109 → 1.0.110
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/dist/model/Controller.d.ts +4 -3
- package/dist/model/Server.d.ts +4 -3
- package/dist/model/Server.js +15 -4
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RequestHandler, Router } from "express";
|
|
2
2
|
import { NormalizePathEntry } from "express-prom-bundle";
|
|
3
|
-
|
|
3
|
+
import { IControllerOptions } from "./IControllerOptions";
|
|
4
|
+
export interface ISingleRouteParam {
|
|
4
5
|
method: "get" | "post" | "patch" | "delete";
|
|
5
6
|
uri: string;
|
|
6
7
|
middlewareAuthorization?: RequestHandler;
|
|
@@ -16,8 +17,8 @@ export declare abstract class Controller {
|
|
|
16
17
|
prefixRole: string[];
|
|
17
18
|
roles: string[];
|
|
18
19
|
byPass: boolean;
|
|
19
|
-
constructor(options:
|
|
20
|
-
registerRoute(options:
|
|
20
|
+
constructor(options: IControllerOptions);
|
|
21
|
+
registerRoute(options: ISingleRouteParam): void;
|
|
21
22
|
}
|
|
22
23
|
export declare function HttpDispatchHandling(target: any, methodName: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
23
24
|
export declare function HttpDispatchDownload(target: any, methodName: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
package/dist/model/Server.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import express
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { Controller } from "./Controller";
|
|
2
3
|
export interface IServerConfig {
|
|
3
4
|
openApiFileOutput: any;
|
|
4
5
|
port: string;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
closeControllers: Controller[];
|
|
7
|
+
openControllers: Controller[];
|
|
7
8
|
i18n: any;
|
|
8
9
|
}
|
|
9
10
|
export declare class Server {
|
package/dist/model/Server.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Server = void 0;
|
|
7
7
|
const c2_util_1 = require("c2-util");
|
|
8
8
|
const express_1 = __importDefault(require("express"));
|
|
9
|
+
const express_prom_bundle_1 = __importDefault(require("express-prom-bundle"));
|
|
9
10
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
10
11
|
const i18n_1 = require("../i18n");
|
|
11
12
|
const MiddlewareGlobals_1 = __importDefault(require("../middleware/global-middleware/MiddlewareGlobals"));
|
|
@@ -22,15 +23,25 @@ class Server {
|
|
|
22
23
|
(0, c2_util_1.log)("LOG_INIT_SERVER", `Initializing server on ${this.config.port}...`);
|
|
23
24
|
(0, i18n_1.initializei18n)(this.config.i18n);
|
|
24
25
|
MiddlewareGlobals_1.default.config(this.app);
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
let pathsToMetrics = [];
|
|
27
|
+
for (const openController of this.config.openControllers) {
|
|
28
|
+
this.app.use(openController.router);
|
|
29
|
+
pathsToMetrics = [...pathsToMetrics, ...openController.normalizedPaths];
|
|
27
30
|
}
|
|
28
31
|
this.app.use("/docs", swagger_ui_express_1.default.serve, swagger_ui_express_1.default.setup(global.OPEN_API_DOC));
|
|
29
32
|
(0, c2_util_1.log)("LOG", "Rotas abertas OK");
|
|
30
33
|
this.app.use(MiddlewareJwt_1.default.config);
|
|
31
|
-
for (const
|
|
32
|
-
this.app.use(router);
|
|
34
|
+
for (const closeRouter of this.config.closeControllers) {
|
|
35
|
+
this.app.use(closeRouter.router);
|
|
36
|
+
pathsToMetrics = [...pathsToMetrics, ...closeRouter.normalizedPaths];
|
|
33
37
|
}
|
|
38
|
+
const metricsMiddleware = (0, express_prom_bundle_1.default)({
|
|
39
|
+
includeMethod: true,
|
|
40
|
+
includePath: true,
|
|
41
|
+
normalizePath: pathsToMetrics,
|
|
42
|
+
metricsPath: "/metrics"
|
|
43
|
+
});
|
|
44
|
+
this.app.use(metricsMiddleware);
|
|
34
45
|
(0, c2_util_1.log)("LOG", "Rotas fechadas OK");
|
|
35
46
|
this.server = this.app.listen(this.config.port, async () => {
|
|
36
47
|
(0, c2_util_1.log)("LOG_INIT_SERVER", `Server running on port ${this.config.port}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.110",
|
|
4
4
|
"description": "Biblioteca Typescript para API NodeJS",
|
|
5
5
|
"repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
|
|
6
6
|
"author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",
|