c2-http 1.0.92 → 1.0.94
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/dto/IHealthcheck.d.ts +15 -0
- package/dist/dto/IHealthcheck.js +2 -0
- package/dist/i18n.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -3
- package/dist/middleware/jwt-middlware/item/GetTokenFlowItem.js +1 -2
- package/dist/model/Controller.js +3 -4
- package/package.json +5 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IHealthcheck {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
uptime: string;
|
|
5
|
+
serverDateTime: string;
|
|
6
|
+
utc0CDateTime: string;
|
|
7
|
+
localDateTime: string;
|
|
8
|
+
startAt: {
|
|
9
|
+
serverDateTime: string;
|
|
10
|
+
utc0DateTime: string;
|
|
11
|
+
localDateTime: string;
|
|
12
|
+
};
|
|
13
|
+
message: string;
|
|
14
|
+
context: any;
|
|
15
|
+
}
|
package/dist/i18n.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { IHealthcheck } from "./dto/IHealthcheck";
|
|
1
2
|
import { IJWTPayload } from "./dto/IJWTPayload";
|
|
2
3
|
import { getMessage, initializei18n } from "./i18n";
|
|
4
|
+
import { MiddlewareCheckScopesFlow } from "./middleware/jwt-middlware/MiddlewareCheckScopesFlow";
|
|
3
5
|
import { Controller, HttpDispatchDownload, HttpDispatchHandling, OpenApi } from "./model/Controller";
|
|
4
6
|
import { ControllerRoleMiddleware } from "./model/ControllerRoleMiddleware";
|
|
5
7
|
import { ControllerRoute, IOpenApiPath } from "./model/ControllerRoute";
|
|
@@ -8,10 +10,9 @@ import { HttpError } from "./model/HttpError";
|
|
|
8
10
|
import { IControllerOptions } from "./model/IControllerOptions";
|
|
9
11
|
import { ICrudControllerOptions } from "./model/ICrudControllerOptions";
|
|
10
12
|
import { IServerConfig, Server } from "./model/Server";
|
|
11
|
-
import { MiddlewareCheckScopesFlow } from "./middleware/jwt-middlware/MiddlewareCheckScopesFlow";
|
|
12
13
|
export declare const convertErrorToHttpError: (error: any) => HttpError;
|
|
13
14
|
export declare const prepareRequestParams: (options?: any) => {
|
|
14
15
|
params: any;
|
|
15
16
|
paramsSerializer: (params: any) => string;
|
|
16
17
|
};
|
|
17
|
-
export { Controller, ControllerRoleMiddleware, ControllerRoute,
|
|
18
|
+
export { Controller, ControllerRoleMiddleware, ControllerRoute, CrudController, getMessage, HttpDispatchDownload, HttpDispatchHandling, IControllerOptions, ICrudControllerOptions, IHealthcheck, IJWTPayload, initializei18n, IOpenApiPath, IServerConfig, MiddlewareCheckScopesFlow, OpenApi, Server };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Server = exports.OpenApi = exports.MiddlewareCheckScopesFlow = exports.initializei18n = exports.HttpDispatchHandling = exports.HttpDispatchDownload = exports.getMessage = exports.CrudController = exports.ControllerRoute = exports.ControllerRoleMiddleware = exports.Controller = exports.prepareRequestParams = exports.convertErrorToHttpError = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
9
9
|
const http_status_1 = require("http-status");
|
|
@@ -13,6 +13,8 @@ const qs_1 = __importDefault(require("qs"));
|
|
|
13
13
|
const i18n_1 = require("./i18n");
|
|
14
14
|
Object.defineProperty(exports, "getMessage", { enumerable: true, get: function () { return i18n_1.getMessage; } });
|
|
15
15
|
Object.defineProperty(exports, "initializei18n", { enumerable: true, get: function () { return i18n_1.initializei18n; } });
|
|
16
|
+
const MiddlewareCheckScopesFlow_1 = require("./middleware/jwt-middlware/MiddlewareCheckScopesFlow");
|
|
17
|
+
Object.defineProperty(exports, "MiddlewareCheckScopesFlow", { enumerable: true, get: function () { return MiddlewareCheckScopesFlow_1.MiddlewareCheckScopesFlow; } });
|
|
16
18
|
const Controller_1 = require("./model/Controller");
|
|
17
19
|
Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return Controller_1.Controller; } });
|
|
18
20
|
Object.defineProperty(exports, "HttpDispatchDownload", { enumerable: true, get: function () { return Controller_1.HttpDispatchDownload; } });
|
|
@@ -27,8 +29,6 @@ Object.defineProperty(exports, "CrudController", { enumerable: true, get: functi
|
|
|
27
29
|
const HttpError_1 = require("./model/HttpError");
|
|
28
30
|
const Server_1 = require("./model/Server");
|
|
29
31
|
Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return Server_1.Server; } });
|
|
30
|
-
const MiddlewareCheckScopesFlow_1 = require("./middleware/jwt-middlware/MiddlewareCheckScopesFlow");
|
|
31
|
-
Object.defineProperty(exports, "MiddlewareCheckScopesFlow", { enumerable: true, get: function () { return MiddlewareCheckScopesFlow_1.MiddlewareCheckScopesFlow; } });
|
|
32
32
|
global.OPEN_API_DOC = {
|
|
33
33
|
"openapi": "3.1.0",
|
|
34
34
|
"info": {
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const c2_util_1 = require("c2-util");
|
|
7
6
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
8
7
|
const http_status_1 = require("http-status");
|
|
9
8
|
const i18n_1 = require("../../../i18n");
|
|
@@ -15,7 +14,7 @@ class GetTokenFlowItem {
|
|
|
15
14
|
throw new HttpError_1.HttpError(http_status_1.FORBIDDEN, (0, i18n_1.getMessage)("message.authentication.tokenIsRequired"));
|
|
16
15
|
}
|
|
17
16
|
const token = headerAuthorization.split(" ")[1];
|
|
18
|
-
if (
|
|
17
|
+
if (!token) {
|
|
19
18
|
throw new HttpError_1.HttpError(http_status_1.FORBIDDEN, (0, i18n_1.getMessage)("message.authentication.tokenIsRequired"));
|
|
20
19
|
}
|
|
21
20
|
return token;
|
package/dist/model/Controller.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenApi = exports.HttpDispatchDownload = exports.HttpDispatchHandling = exports.Controller = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
-
const c2_util_1 = require("c2-util");
|
|
6
4
|
const express_1 = require("express");
|
|
7
5
|
const http_status_1 = require("http-status");
|
|
8
6
|
class Controller {
|
|
@@ -17,10 +15,10 @@ class Controller {
|
|
|
17
15
|
if (this.options.basePath === undefined) {
|
|
18
16
|
this.options.basePath = "";
|
|
19
17
|
}
|
|
20
|
-
if (
|
|
18
|
+
if (!this.options?.roles) {
|
|
21
19
|
this.options.roles = [];
|
|
22
20
|
}
|
|
23
|
-
if (
|
|
21
|
+
if (!this.options?.prefixRole) {
|
|
24
22
|
let defaultPrefixRole = this.options.relativePath;
|
|
25
23
|
if (defaultPrefixRole.startsWith("/")) {
|
|
26
24
|
defaultPrefixRole = defaultPrefixRole.replace("/", "");
|
|
@@ -56,6 +54,7 @@ exports.HttpDispatchHandling = HttpDispatchHandling;
|
|
|
56
54
|
function HttpDispatchDownload(target, methodName, descriptor) {
|
|
57
55
|
const originalMethod = descriptor.value;
|
|
58
56
|
descriptor.value = async function (...args) {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
59
58
|
const [request, response] = args;
|
|
60
59
|
try {
|
|
61
60
|
const [status, data] = await originalMethod.apply(this, args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.94",
|
|
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>",
|
|
@@ -25,29 +25,29 @@
|
|
|
25
25
|
"@types/mongoose": "^5.11.97",
|
|
26
26
|
"@types/swagger-ui-express": "^4.1.6",
|
|
27
27
|
"axios": "^1.6.8",
|
|
28
|
-
"c2-util": "^1.0.
|
|
28
|
+
"c2-util": "^1.0.28",
|
|
29
29
|
"cookie-parser": "^1.4.7",
|
|
30
30
|
"cors": "^2.8.5",
|
|
31
31
|
"express": "^4.19.2",
|
|
32
32
|
"express-http-context": "^1.2.4",
|
|
33
33
|
"express-rest-i18n": "^1.0.1",
|
|
34
34
|
"http-status": "^1.7.4",
|
|
35
|
+
"jsonwebtoken": "^9.0.0",
|
|
35
36
|
"moment": "^2.30.1",
|
|
36
37
|
"mongoose": "^8.3.4",
|
|
37
38
|
"qs": "^6.13.0",
|
|
38
39
|
"swagger-autogen": "^2.23.7",
|
|
39
40
|
"swagger-ui-express": "^5.0.0",
|
|
40
41
|
"ts-node": "^10.8.1",
|
|
41
|
-
"typescript": "^4.7.4"
|
|
42
|
-
"jsonwebtoken": "^9.0.0"
|
|
42
|
+
"typescript": "^4.7.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/cookie-parser": "^1.4.7",
|
|
46
46
|
"@types/cors": "^2.8.13",
|
|
47
|
+
"@types/jsonwebtoken": "^8.5.8",
|
|
47
48
|
"@types/node": "^20.12.11",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
49
50
|
"@typescript-eslint/parser": "^7.8.0",
|
|
50
|
-
"@types/jsonwebtoken": "^8.5.8",
|
|
51
51
|
"eslint": "^9.2.0",
|
|
52
52
|
"typescript-eslint": "^7.8.0"
|
|
53
53
|
}
|