@6thbridge/utils 0.1.16
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/lib/actions/charge.action.d.ts +9 -0
- package/lib/actions/charge.action.js +74 -0
- package/lib/actions/charge.action.js.map +1 -0
- package/lib/actions/currency.action.d.ts +15 -0
- package/lib/actions/currency.action.js +57 -0
- package/lib/actions/currency.action.js.map +1 -0
- package/lib/actions/index.d.ts +9 -0
- package/lib/actions/index.js +33 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/phone-number.action.d.ts +23 -0
- package/lib/actions/phone-number.action.js +77 -0
- package/lib/actions/phone-number.action.js.map +1 -0
- package/lib/brokers/index.d.ts +6 -0
- package/lib/brokers/index.js +8 -0
- package/lib/brokers/index.js.map +1 -0
- package/lib/brokers/kafka.d.ts +84 -0
- package/lib/brokers/kafka.js +265 -0
- package/lib/brokers/kafka.js.map +1 -0
- package/lib/brokers/kafka.test.d.ts +1 -0
- package/lib/brokers/kafka.test.js +118 -0
- package/lib/brokers/kafka.test.js.map +1 -0
- package/lib/brokers/rabbitmq.d.ts +108 -0
- package/lib/brokers/rabbitmq.js +290 -0
- package/lib/brokers/rabbitmq.js.map +1 -0
- package/lib/cache/in-memory.d.ts +0 -0
- package/lib/cache/in-memory.js +2 -0
- package/lib/cache/in-memory.js.map +1 -0
- package/lib/cache/redis.d.ts +18 -0
- package/lib/cache/redis.js +58 -0
- package/lib/cache/redis.js.map +1 -0
- package/lib/database/MongoDBRepository.d.ts +23 -0
- package/lib/database/MongoDBRepository.js +90 -0
- package/lib/database/MongoDBRepository.js.map +1 -0
- package/lib/database/MongoDBTypeRepository.d.ts +26 -0
- package/lib/database/MongoDBTypeRepository.js +90 -0
- package/lib/database/MongoDBTypeRepository.js.map +1 -0
- package/lib/database/index.d.ts +4 -0
- package/lib/database/index.js +36 -0
- package/lib/database/index.js.map +1 -0
- package/lib/database/query.d.ts +16 -0
- package/lib/database/query.js +82 -0
- package/lib/database/query.js.map +1 -0
- package/lib/exceptions/custom.exception.d.ts +14 -0
- package/lib/exceptions/custom.exception.js +16 -0
- package/lib/exceptions/custom.exception.js.map +1 -0
- package/lib/helpers/errors.d.ts +2 -0
- package/lib/helpers/errors.js +46 -0
- package/lib/helpers/errors.js.map +1 -0
- package/lib/helpers/index.d.ts +51 -0
- package/lib/helpers/index.js +198 -0
- package/lib/helpers/index.js.map +1 -0
- package/lib/helpers/utils.d.ts +9 -0
- package/lib/helpers/utils.js +18 -0
- package/lib/helpers/utils.js.map +1 -0
- package/lib/http/axios.d.ts +0 -0
- package/lib/http/axios.js +2 -0
- package/lib/http/axios.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +104 -0
- package/lib/index.js.map +1 -0
- package/lib/logger/index.d.ts +20 -0
- package/lib/logger/index.js +12 -0
- package/lib/logger/index.js.map +1 -0
- package/lib/logger/logger-test.d.ts +1 -0
- package/lib/logger/logger-test.js +40 -0
- package/lib/logger/logger-test.js.map +1 -0
- package/lib/logger/logger.d.ts +31 -0
- package/lib/logger/logger.js +106 -0
- package/lib/logger/logger.js.map +1 -0
- package/lib/logger/null-logger.d.ts +14 -0
- package/lib/logger/null-logger.js +29 -0
- package/lib/logger/null-logger.js.map +1 -0
- package/lib/logger/test.d.ts +1 -0
- package/lib/logger/test.js +45 -0
- package/lib/logger/test.js.map +1 -0
- package/lib/middlewares/common.d.ts +22 -0
- package/lib/middlewares/common.js +141 -0
- package/lib/middlewares/common.js.map +1 -0
- package/lib/middlewares/express.d.ts +4 -0
- package/lib/middlewares/express.js +99 -0
- package/lib/middlewares/express.js.map +1 -0
- package/lib/middlewares/fastify.d.ts +4 -0
- package/lib/middlewares/fastify.js +73 -0
- package/lib/middlewares/fastify.js.map +1 -0
- package/lib/middlewares/index.d.ts +4 -0
- package/lib/middlewares/index.js +34 -0
- package/lib/middlewares/index.js.map +1 -0
- package/lib/monitoring/index.d.ts +12 -0
- package/lib/monitoring/index.js +75 -0
- package/lib/monitoring/index.js.map +1 -0
- package/lib/responses/express.d.ts +26 -0
- package/lib/responses/express.js +98 -0
- package/lib/responses/express.js.map +1 -0
- package/lib/responses/fastify.d.ts +4 -0
- package/lib/responses/fastify.js +25 -0
- package/lib/responses/fastify.js.map +1 -0
- package/lib/responses/index.d.ts +3 -0
- package/lib/responses/index.js +31 -0
- package/lib/responses/index.js.map +1 -0
- package/lib/secrets/aws-secret.d.ts +4 -0
- package/lib/secrets/aws-secret.js +55 -0
- package/lib/secrets/aws-secret.js.map +1 -0
- package/lib/secrets/aws.d.ts +0 -0
- package/lib/secrets/aws.js +2 -0
- package/lib/secrets/aws.js.map +1 -0
- package/lib/secrets/index.d.ts +8 -0
- package/lib/secrets/index.js +18 -0
- package/lib/secrets/index.js.map +1 -0
- package/lib/test/actions/charge.action.test.d.ts +1 -0
- package/lib/test/actions/charge.action.test.js +86 -0
- package/lib/test/actions/charge.action.test.js.map +1 -0
- package/lib/test/database/test.spec.d.ts +1 -0
- package/lib/test/database/test.spec.js +74 -0
- package/lib/test/database/test.spec.js.map +1 -0
- package/lib/test/helpers/PhoneNumber.spec.d.ts +1 -0
- package/lib/test/helpers/PhoneNumber.spec.js +82 -0
- package/lib/test/helpers/PhoneNumber.spec.js.map +1 -0
- package/lib/test/logger/test.spec.d.ts +1 -0
- package/lib/test/logger/test.spec.js +37 -0
- package/lib/test/logger/test.spec.js.map +1 -0
- package/lib/test/types/context.entity.test.d.ts +1 -0
- package/lib/test/types/context.entity.test.js +29 -0
- package/lib/test/types/context.entity.test.js.map +1 -0
- package/lib/translations/index.d.ts +7 -0
- package/lib/translations/index.js +52 -0
- package/lib/translations/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/broker.entity.d.ts +15 -0
- package/lib/types/broker.entity.js +13 -0
- package/lib/types/broker.entity.js.map +1 -0
- package/lib/types/client.entity.d.ts +42 -0
- package/lib/types/client.entity.js +16 -0
- package/lib/types/client.entity.js.map +1 -0
- package/lib/types/context.entity.d.ts +43 -0
- package/lib/types/context.entity.js +105 -0
- package/lib/types/context.entity.js.map +1 -0
- package/lib/types/index.d.ts +82 -0
- package/lib/types/index.js +38 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/user.entity.d.ts +28 -0
- package/lib/types/user.entity.js +18 -0
- package/lib/types/user.entity.js.map +1 -0
- package/package.json +52 -0
- package/readme.md +66 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.types = exports.exceptions = exports.secrets = exports.monitoring = exports.LOG_LEVEL = exports.LoggerProps = exports.NullLogger = exports.Logger = exports.brokers = exports.translations = exports.middlewares = exports.helpers = exports.responses = exports.databases = exports.dayjs = exports.actions = exports.logger = exports.axios = void 0;
|
|
30
|
+
const axios_1 = __importDefault(require("axios"));
|
|
31
|
+
exports.axios = axios_1.default;
|
|
32
|
+
const logger_1 = require("./logger/logger");
|
|
33
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
34
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
35
|
+
Object.defineProperty(exports, "LoggerProps", { enumerable: true, get: function () { return logger_1.LoggerProps; } });
|
|
36
|
+
const logger_2 = require("./logger");
|
|
37
|
+
Object.defineProperty(exports, "LOG_LEVEL", { enumerable: true, get: function () { return logger_2.LOG_LEVEL; } });
|
|
38
|
+
const null_logger_1 = require("./logger/null-logger");
|
|
39
|
+
Object.defineProperty(exports, "NullLogger", { enumerable: true, get: function () { return null_logger_1.NullLogger; } });
|
|
40
|
+
const middlewares = __importStar(require("./middlewares"));
|
|
41
|
+
exports.middlewares = middlewares;
|
|
42
|
+
const helpers = __importStar(require("./helpers"));
|
|
43
|
+
exports.helpers = helpers;
|
|
44
|
+
const responses = __importStar(require("./responses"));
|
|
45
|
+
exports.responses = responses;
|
|
46
|
+
const databases = __importStar(require("./database"));
|
|
47
|
+
exports.databases = databases;
|
|
48
|
+
const brokers = __importStar(require("./brokers"));
|
|
49
|
+
exports.brokers = brokers;
|
|
50
|
+
const monitoring = __importStar(require("./monitoring"));
|
|
51
|
+
exports.monitoring = monitoring;
|
|
52
|
+
const secrets = __importStar(require("./secrets"));
|
|
53
|
+
exports.secrets = secrets;
|
|
54
|
+
const exceptions = __importStar(require("./exceptions/custom.exception"));
|
|
55
|
+
exports.exceptions = exceptions;
|
|
56
|
+
const translations = __importStar(require("./translations"));
|
|
57
|
+
exports.translations = translations;
|
|
58
|
+
const actions_1 = __importDefault(require("./actions"));
|
|
59
|
+
exports.actions = actions_1.default;
|
|
60
|
+
const types = __importStar(require("./types"));
|
|
61
|
+
exports.types = types;
|
|
62
|
+
const { dayjs } = helpers;
|
|
63
|
+
exports.dayjs = dayjs;
|
|
64
|
+
process.on('uncaughtException', err => {
|
|
65
|
+
logger_1.logger.critical("uncaughtException: " + err.message, {}, err.stack);
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
process.exit(1); //mandatory (as per the Node.js docs)
|
|
68
|
+
}, 5000);
|
|
69
|
+
});
|
|
70
|
+
process.on("uncaughtRejection", (err) => {
|
|
71
|
+
logger_1.logger.critical("uncaughtRejection: " + err.message, {}, err.stack);
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
process.exit(1); //mandatory (as per the Node.js docs)
|
|
74
|
+
}, 5000);
|
|
75
|
+
});
|
|
76
|
+
process.on("unhandledRejection", (err) => {
|
|
77
|
+
logger_1.logger.critical("unhandledRejection: " + err.message, {}, err.stack);
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
process.exit(1); //mandatory (as per the Node.js docs)
|
|
80
|
+
}, 5000);
|
|
81
|
+
});
|
|
82
|
+
process.on('uncaughtExceptionMonitor', (err, origin) => {
|
|
83
|
+
logger_1.logger.critical("uncaughtExceptionMonitor: " + err.message, {
|
|
84
|
+
origin
|
|
85
|
+
}, err.stack);
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
process.exit(1); //mandatory (as per the Node.js docs)
|
|
88
|
+
}, 5000);
|
|
89
|
+
});
|
|
90
|
+
process.on('warning', (warning) => {
|
|
91
|
+
logger_1.logger.warn("PROCESS-WARNING: " + warning.message, {
|
|
92
|
+
name: warning.name,
|
|
93
|
+
stack: warning.stack
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
process.on('SIGTERM', (signal) => {
|
|
97
|
+
logger_1.logger.warn(`SIGTERM: ${process.env.APP_NAME || signal} is shutting down`, {
|
|
98
|
+
name: signal.name,
|
|
99
|
+
});
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
process.exit(1); //mandatory (as per the Node.js docs)
|
|
102
|
+
}, 5000);
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAkBtB,gBAlBG,eAAK,CAkBH;AAjBT,4CAA4D;AAkBxD,uFAlBI,eAAM,OAkBJ;AASN,uFA3BY,eAAM,OA2BZ;AAEN,4FA7BoB,oBAAW,OA6BpB;AA5Bf,qCAAoD;AA8BhD,0FA9BI,kBAAS,OA8BJ;AA7Bb,sDAAgD;AA0B5C,2FA1BI,wBAAU,OA0BJ;AAzBd,2DAA6C;AAqBzC,kCAAW;AApBf,mDAAqC;AAmBjC,0BAAO;AAlBX,uDAAyC;AAiBrC,8BAAS;AAhBb,sDAAwC;AAepC,8BAAS;AAdb,mDAAqC;AAmBjC,0BAAO;AAlBX,yDAA2C;AAwBvC,gCAAU;AAvBd,mDAAqC;AAwBjC,0BAAO;AAvBX,0EAA4D;AAwBxD,gCAAU;AAvBd,6DAA+C;AAc3C,oCAAY;AAbhB,wDAAgC;AAO5B,kBAPG,iBAAO,CAOH;AANX,+CAAiC;AAsB7B,sBAAK;AArBT,MAAO,EAAC,KAAK,EAAC,GAAG,OAAO,CAAC;AAMrB,sBAAK;AAmBT,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAE;IAClC,eAAM,CAAC,QAAQ,CAAC,qBAAqB,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACpE,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC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AAE;QAC/C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACvB,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,MAAW,EAAE,EAAE;IAClC,eAAM,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,MAAM,mBAAmB,EAAE;QACvE,IAAI,EAAE,MAAM,CAAC,IAAI;KACpB,CAAC,CAAC;IACH,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,qCAAqC;IACzD,CAAC,EAAE,IAAI,CAAC,CAAC;AACb,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum LOG_LEVEL {
|
|
2
|
+
ERROR = "error",
|
|
3
|
+
WARN = "warn",
|
|
4
|
+
INFO = "info",
|
|
5
|
+
DEBUG = "debug",
|
|
6
|
+
CRITICAL = "critical"
|
|
7
|
+
}
|
|
8
|
+
export interface LoggerInterface {
|
|
9
|
+
configureLogger(prop: any): any;
|
|
10
|
+
setBroker(broker: any): any;
|
|
11
|
+
setProps(props: any): any;
|
|
12
|
+
log(level: LOG_LEVEL, message: string, data?: any, trace?: string): any;
|
|
13
|
+
error(message: string, meta?: any, trace?: string): any;
|
|
14
|
+
warn(message: string, meta?: any, trace?: string): any;
|
|
15
|
+
debug(message: string, meta?: any, trace?: string): any;
|
|
16
|
+
info(message: string, meta?: any, trace?: string): any;
|
|
17
|
+
critical(message: string, meta?: any, trace?: string): any;
|
|
18
|
+
exception(error: Error, meta?: any): any;
|
|
19
|
+
out(...args: any): any;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LOG_LEVEL = void 0;
|
|
4
|
+
var LOG_LEVEL;
|
|
5
|
+
(function (LOG_LEVEL) {
|
|
6
|
+
LOG_LEVEL["ERROR"] = "error";
|
|
7
|
+
LOG_LEVEL["WARN"] = "warn";
|
|
8
|
+
LOG_LEVEL["INFO"] = "info";
|
|
9
|
+
LOG_LEVEL["DEBUG"] = "debug";
|
|
10
|
+
LOG_LEVEL["CRITICAL"] = "critical";
|
|
11
|
+
})(LOG_LEVEL || (exports.LOG_LEVEL = LOG_LEVEL = {}));
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAMX;AAND,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,0BAAa,CAAA;IACb,4BAAe,CAAA;IACf,kCAAqB,CAAA;AACzB,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//ts-node test.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const logger_1 = require("./logger");
|
|
14
|
+
const helpers_1 = require("../helpers");
|
|
15
|
+
function testLogger() {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const logger = new logger_1.Logger({
|
|
18
|
+
requestId: "123",
|
|
19
|
+
requestClientId: "client-id",
|
|
20
|
+
contextClientId: "context-client-id",
|
|
21
|
+
level: "info",
|
|
22
|
+
});
|
|
23
|
+
logger.info("Another info message", {
|
|
24
|
+
info: 1
|
|
25
|
+
});
|
|
26
|
+
logger.critical("Another critical message", {
|
|
27
|
+
critical: 1
|
|
28
|
+
});
|
|
29
|
+
logger.error("Another error message", {
|
|
30
|
+
error: 1
|
|
31
|
+
}, "stack trace here");
|
|
32
|
+
logger.warn("Another warn message", {
|
|
33
|
+
warn: 1
|
|
34
|
+
});
|
|
35
|
+
logger.out("Logging Debug Message", "and anotheer", "well 123", 456);
|
|
36
|
+
yield (0, helpers_1.sleep)(1000000000);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
testLogger();
|
|
40
|
+
//# sourceMappingURL=logger-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-test.js","sourceRoot":"","sources":["../../src/logger/logger-test.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;;;;;;;;;AAGjB,qCAAgC;AAChC,wCAAiC;AAGjC,SAAe,UAAU;;QACrB,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;YACtB,SAAS,EAAE,KAAK;YAChB,eAAe,EAAE,WAAW;YAC5B,eAAe,EAAE,mBAAmB;YACpC,KAAK,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAG;YACjC,IAAI,EAAE,CAAC;SACV,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,0BAA0B,EAAG;YACzC,QAAQ,EAAE,CAAC;SACd,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAG;YACnC,KAAK,EAAE,CAAC;SACX,EAAE,kBAAkB,CAAC,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAG;YACjC,IAAI,EAAE,CAAC;SACV,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACrE,MAAM,IAAA,eAAK,EAAC,UAAU,CAAC,CAAA;IAC3B,CAAC;CAAA;AAED,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LOG_LEVEL, LoggerInterface } from "./index";
|
|
2
|
+
import { RabbitMQ } from "../brokers";
|
|
3
|
+
export declare class LoggerProps {
|
|
4
|
+
service?: string;
|
|
5
|
+
requestId?: string;
|
|
6
|
+
requestClientId?: string;
|
|
7
|
+
contextClientId?: string;
|
|
8
|
+
ip?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
logsQueue?: string;
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export declare class Logger implements LoggerInterface {
|
|
14
|
+
private props;
|
|
15
|
+
private broker?;
|
|
16
|
+
private meta;
|
|
17
|
+
constructor(props: LoggerProps, broker?: RabbitMQ | undefined);
|
|
18
|
+
configureLogger(prop: any): any;
|
|
19
|
+
setBroker(broker: RabbitMQ): void;
|
|
20
|
+
setProps(props: LoggerProps): any;
|
|
21
|
+
log(level: LOG_LEVEL, message: string, data?: any, trace?: string): void;
|
|
22
|
+
postHttp(payload: any): void;
|
|
23
|
+
error(message: string, meta?: any, trace?: string): void;
|
|
24
|
+
warn(message: string, meta?: any, trace?: string): void;
|
|
25
|
+
debug(message: string, meta?: any, trace?: string): void;
|
|
26
|
+
info(message: string, meta?: any, trace?: string): void;
|
|
27
|
+
critical(message: string, meta?: any, trace?: string): void;
|
|
28
|
+
exception(error: Error, meta?: any): void;
|
|
29
|
+
out(...args: any): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const logger: Logger;
|
|
@@ -0,0 +1,106 @@
|
|
|
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.logger = exports.Logger = exports.LoggerProps = void 0;
|
|
7
|
+
const index_1 = require("./index");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const _axios = axios_1.default.create({
|
|
11
|
+
baseURL: process.env.UTILITY_SERVICE_URL || "http://utility-service",
|
|
12
|
+
headers: {
|
|
13
|
+
source: "internal"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
class LoggerProps {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.service = process.env.APP_NAME || "app";
|
|
19
|
+
this.logsQueue = "platform.logs";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.LoggerProps = LoggerProps;
|
|
23
|
+
class Logger {
|
|
24
|
+
constructor(props, broker) {
|
|
25
|
+
this.props = props;
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.meta = {
|
|
28
|
+
service: this.props.service || process.env.APP_NAME,
|
|
29
|
+
requestId: this.props.requestId,
|
|
30
|
+
requestClientId: this.props.requestClientId,
|
|
31
|
+
contextClientId: this.props.contextClientId,
|
|
32
|
+
userId: this.props.userId,
|
|
33
|
+
requestSource: this.props.requestSource,
|
|
34
|
+
ip: this.props.ip,
|
|
35
|
+
url: this.props.url,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
configureLogger(prop) {
|
|
39
|
+
return Object.assign(Object.assign({}, this.props), prop);
|
|
40
|
+
}
|
|
41
|
+
setBroker(broker) {
|
|
42
|
+
this.broker = broker;
|
|
43
|
+
}
|
|
44
|
+
setProps(props) {
|
|
45
|
+
return this.configureLogger(props);
|
|
46
|
+
}
|
|
47
|
+
log(level, message, data = {}, trace) {
|
|
48
|
+
var _a;
|
|
49
|
+
const payload = Object.assign(Object.assign(Object.assign({}, data), { level,
|
|
50
|
+
message }), this.meta);
|
|
51
|
+
if (level == index_1.LOG_LEVEL.DEBUG) {
|
|
52
|
+
return this.out(payload);
|
|
53
|
+
}
|
|
54
|
+
this.out(payload);
|
|
55
|
+
if ([index_1.LOG_LEVEL.CRITICAL, index_1.LOG_LEVEL.ERROR].includes(level)) {
|
|
56
|
+
payload.stack = trace || new Error().stack;
|
|
57
|
+
}
|
|
58
|
+
if (!(0, lodash_1.isEmpty)(this.broker)) {
|
|
59
|
+
(_a = this.broker) === null || _a === void 0 ? void 0 : _a.sendToQueue(this.props.logsQueue || "platform.logs", payload).catch(e => {
|
|
60
|
+
console.error(e.message, payload);
|
|
61
|
+
return this.postHttp(payload);
|
|
62
|
+
});
|
|
63
|
+
this.out("====== log sent via broker =====");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
return this.postHttp(payload);
|
|
67
|
+
}
|
|
68
|
+
postHttp(payload) {
|
|
69
|
+
_axios.post("/v1/logs", payload)
|
|
70
|
+
.catch(error => {
|
|
71
|
+
console.error(error.message, payload);
|
|
72
|
+
});
|
|
73
|
+
this.out("====== log sent via http =====");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
error(message, meta = {}, trace = "") {
|
|
77
|
+
console.error("error", message, meta);
|
|
78
|
+
return this.log(index_1.LOG_LEVEL.ERROR, message, meta, trace);
|
|
79
|
+
}
|
|
80
|
+
warn(message, meta = {}, trace = "") {
|
|
81
|
+
return this.log(index_1.LOG_LEVEL.WARN, message, meta, trace);
|
|
82
|
+
}
|
|
83
|
+
debug(message, meta = {}, trace = "") {
|
|
84
|
+
return this.log(index_1.LOG_LEVEL.DEBUG, message, meta, trace);
|
|
85
|
+
}
|
|
86
|
+
info(message, meta = {}, trace = "") {
|
|
87
|
+
return this.log(index_1.LOG_LEVEL.INFO, message, meta, trace);
|
|
88
|
+
}
|
|
89
|
+
critical(message, meta, trace = "") {
|
|
90
|
+
meta.critical = 1;
|
|
91
|
+
console.error("critical", message, meta, trace);
|
|
92
|
+
return this.log(index_1.LOG_LEVEL.ERROR, message, meta, trace);
|
|
93
|
+
}
|
|
94
|
+
exception(error, meta = {}) {
|
|
95
|
+
meta.exception = 1;
|
|
96
|
+
console.error("exception", error, meta);
|
|
97
|
+
return this.log(index_1.LOG_LEVEL.ERROR, error.message, meta, error.stack);
|
|
98
|
+
}
|
|
99
|
+
out(...args) {
|
|
100
|
+
if (process.env.LOG_OUT)
|
|
101
|
+
console.log(...args);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.Logger = Logger;
|
|
105
|
+
exports.logger = new Logger({});
|
|
106
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmD;AAEnD,mCAA+B;AAC/B,kDAA0B;AAE1B,MAAM,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,wBAAwB;IACpE,OAAO,EAAE;QACL,MAAM,EAAE,UAAU;KACrB;CACJ,CAAC,CAAC;AACH,MAAa,WAAW;IAAxB;QACI,YAAO,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK,CAAC;QAMjD,cAAS,GAAY,eAAe,CAAC;IAEzC,CAAC;CAAA;AATD,kCASC;AAED,MAAa,MAAM;IAEf,YAAoB,KAAkB,EAAU,MAAiB;QAA7C,UAAK,GAAL,KAAK,CAAa;QAAU,WAAM,GAAN,MAAM,CAAW;QAC7D,IAAI,CAAC,IAAI,GAAG;YACR,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;YACnD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,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AAe,EAAE,OAAY,EAAE,EAAE,QAAgB,EAAE;QACpD,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,IAAU,EAAE,QAAgB,EAAE;QACpD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;QACjB,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAGD,SAAS,CAAC,KAAY,EAAE,OAAY,EAAE;QAClC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAS,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACtE,CAAC;IAED,GAAG,CAAC,GAAG,IAAS;QACZ,IAAG,OAAO,CAAC,GAAG,CAAC,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,CAAC;CACJ;AA5GD,wBA4GC;AAEY,QAAA,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LOG_LEVEL, LoggerInterface } from "./index";
|
|
2
|
+
export declare class NullLogger implements LoggerInterface {
|
|
3
|
+
configureLogger(prop: any): any;
|
|
4
|
+
critical(message: string, meta: any, trace?: string): any;
|
|
5
|
+
debug(message: string, meta: any, trace?: string): any;
|
|
6
|
+
error(message: string, meta: any, trace?: string): any;
|
|
7
|
+
exception(error: Error, meta: any): any;
|
|
8
|
+
info(message: string, meta: any, trace?: string): any;
|
|
9
|
+
log(level: LOG_LEVEL, message: string, data: any, trace?: string): any;
|
|
10
|
+
out(...args: any): any;
|
|
11
|
+
setBroker(broker: any): any;
|
|
12
|
+
setProps(props: any): any;
|
|
13
|
+
warn(message: string, meta: any, trace?: string): any;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NullLogger = void 0;
|
|
4
|
+
class NullLogger {
|
|
5
|
+
configureLogger(prop) {
|
|
6
|
+
}
|
|
7
|
+
critical(message, meta, trace) {
|
|
8
|
+
}
|
|
9
|
+
debug(message, meta, trace) {
|
|
10
|
+
}
|
|
11
|
+
error(message, meta, trace) {
|
|
12
|
+
}
|
|
13
|
+
exception(error, meta) {
|
|
14
|
+
}
|
|
15
|
+
info(message, meta, trace) {
|
|
16
|
+
}
|
|
17
|
+
log(level, message, data, trace) {
|
|
18
|
+
}
|
|
19
|
+
out(...args) {
|
|
20
|
+
}
|
|
21
|
+
setBroker(broker) {
|
|
22
|
+
}
|
|
23
|
+
setProps(props) {
|
|
24
|
+
}
|
|
25
|
+
warn(message, meta, trace) {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.NullLogger = NullLogger;
|
|
29
|
+
//# sourceMappingURL=null-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null-logger.js","sourceRoot":"","sources":["../../src/logger/null-logger.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IACnB,eAAe,CAAC,IAAS;IACzB,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,IAAS,EAAE,KAAc;IACnD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAS,EAAE,KAAc;IAChD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAS,EAAE,KAAc;IAChD,CAAC;IAED,SAAS,CAAC,KAAY,EAAE,IAAS;IACjC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAS,EAAE,KAAc;IAC/C,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,IAAS,EAAE,KAAc;IAChE,CAAC;IAED,GAAG,CAAC,GAAG,IAAS;IAChB,CAAC;IAED,SAAS,CAAC,MAAW;IACrB,CAAC;IAED,QAAQ,CAAC,KAAU;IACnB,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,IAAS,EAAE,KAAc;IAC/C,CAAC;CAEJ;AAlCD,gCAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//ts-node test.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const logger_1 = require("./logger");
|
|
17
|
+
const winston_1 = __importDefault(require("winston"));
|
|
18
|
+
const helpers_1 = require("../helpers");
|
|
19
|
+
function testLogger() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const logger = new logger_1.Logger({
|
|
22
|
+
requestId: "123",
|
|
23
|
+
requestClientId: "client-id",
|
|
24
|
+
contextClientId: "context-client-id",
|
|
25
|
+
format: winston_1.default.format.json(),
|
|
26
|
+
level: "info",
|
|
27
|
+
});
|
|
28
|
+
logger.info("Another info message", {
|
|
29
|
+
info: 1
|
|
30
|
+
});
|
|
31
|
+
logger.critical("Another critical message", {
|
|
32
|
+
critical: 1
|
|
33
|
+
});
|
|
34
|
+
logger.error("Another error message", {
|
|
35
|
+
error: 1
|
|
36
|
+
}, "stack trace here");
|
|
37
|
+
logger.warn("Another warn message", {
|
|
38
|
+
warn: 1
|
|
39
|
+
});
|
|
40
|
+
logger.out("Logging Debug Message", "and anotheer", "well 123", 456);
|
|
41
|
+
yield (0, helpers_1.sleep)(1000000000);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
testLogger();
|
|
45
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/logger/test.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;;;;;;;;;;;;AAGjB,qCAAgC;AAChC,sDAA8B;AAC9B,wCAAiC;AAGjC,SAAe,UAAU;;QACrB,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;YACtB,SAAS,EAAE,KAAK;YAChB,eAAe,EAAE,WAAW;YAC5B,eAAe,EAAE,mBAAmB;YACpC,MAAM,EAAE,iBAAO,CAAC,MAAM,CAAC,IAAI,EAAE;YAC7B,KAAK,EAAE,MAAM;SAChB,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAG;YACjC,IAAI,EAAE,CAAC;SACV,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,0BAA0B,EAAG;YACzC,QAAQ,EAAE,CAAC;SACd,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAG;YACnC,KAAK,EAAE,CAAC;SACX,EAAE,kBAAkB,CAAC,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAG;YACjC,IAAI,EAAE,CAAC;SACV,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACrE,MAAM,IAAA,eAAK,EAAC,UAAU,CAAC,CAAA;IAC3B,CAAC;CAAA;AAED,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const AUTHENTICATION_TYPES: {
|
|
2
|
+
CLIENT_ID: string;
|
|
3
|
+
CLIENT_SECRET: string;
|
|
4
|
+
JWT: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function getContext(req: any, supportedAuthenticationType?: string[], permissions?: string[]): Promise<any>;
|
|
7
|
+
export declare function unless(middlewareName: string, paths: string[], middleware: any): ((req: any, res: any, next: any) => any) | undefined;
|
|
8
|
+
interface APIToolKitConfig {
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
env?: string;
|
|
12
|
+
excludePaths?: string[];
|
|
13
|
+
redactHeaders?: string[];
|
|
14
|
+
redactRequestBody?: string[];
|
|
15
|
+
redactResponseBody?: string[];
|
|
16
|
+
tags?: string[];
|
|
17
|
+
serviceVersion?: string;
|
|
18
|
+
environment?: string;
|
|
19
|
+
rawApiToolkitConfig?: Record<any, any>;
|
|
20
|
+
}
|
|
21
|
+
export declare const apitoolkitMiddleware: (config?: APIToolKitConfig) => ((req: any, res: any, next: any) => any) | undefined;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.apitoolkitMiddleware = exports.unless = exports.getContext = exports.AUTHENTICATION_TYPES = void 0;
|
|
16
|
+
const types_1 = require("../types");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const lodash_1 = require("lodash");
|
|
19
|
+
const logger_1 = require("../logger/logger");
|
|
20
|
+
const apitoolkit_express_1 = __importDefault(require("apitoolkit-express"));
|
|
21
|
+
const path_to_regexp_1 = require("path-to-regexp");
|
|
22
|
+
const _axios = axios_1.default.create({
|
|
23
|
+
baseURL: process.env.USER_SERVICE_URL || "http://user-service",
|
|
24
|
+
headers: {
|
|
25
|
+
source: "internal"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exports.AUTHENTICATION_TYPES = {
|
|
29
|
+
CLIENT_ID: "client-id",
|
|
30
|
+
CLIENT_SECRET: "client-secret",
|
|
31
|
+
JWT: "jwt"
|
|
32
|
+
};
|
|
33
|
+
function getContext(req, supportedAuthenticationType, permissions) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
|
+
try {
|
|
37
|
+
let context = types_1.ContextEntity.fromRequest(req);
|
|
38
|
+
if (context.requestSource === types_1.INTERNAL_REQUEST_SOURCE) {
|
|
39
|
+
context.logger.out("Auth: =================== internal request =============");
|
|
40
|
+
return { data: context };
|
|
41
|
+
}
|
|
42
|
+
if (req.headers.isExcluded || req.headers['is-excluded']) {
|
|
43
|
+
context.logger.out("Auth: =================== internal request =============");
|
|
44
|
+
return { data: context };
|
|
45
|
+
}
|
|
46
|
+
if (supportedAuthenticationType == null || (0, lodash_1.isEmpty)(supportedAuthenticationType)) {
|
|
47
|
+
context.logger.out("Auth: Empty supportedAuthenticationType");
|
|
48
|
+
return { data: context };
|
|
49
|
+
}
|
|
50
|
+
if (!context.authenticationType || !supportedAuthenticationType.includes(context.authenticationType)) {
|
|
51
|
+
context.logger.out(context.authenticationType, supportedAuthenticationType, req.headers);
|
|
52
|
+
throw new Error("invalid authentication type for this request");
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
if (req.headers["context-client"])
|
|
56
|
+
context.contextClient = JSON.parse(req.headers["context-client"]);
|
|
57
|
+
if (req.headers["request-client"])
|
|
58
|
+
context.requestClient = JSON.parse(req.headers["request-client"]);
|
|
59
|
+
//process users
|
|
60
|
+
if (req.headers["request-user"])
|
|
61
|
+
context.requestUser = JSON.parse(req.headers["request-user"]);
|
|
62
|
+
if (req.headers["context-user"])
|
|
63
|
+
context.contextUser = JSON.parse(req.headers["context-user"]);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
context.logger.exception(e);
|
|
67
|
+
}
|
|
68
|
+
//filter out non JWT
|
|
69
|
+
if (context.authenticationType != exports.AUTHENTICATION_TYPES.JWT) {
|
|
70
|
+
context.logger.out("Auth: Non JWT authenticationType exit");
|
|
71
|
+
return { data: context };
|
|
72
|
+
}
|
|
73
|
+
if (!(permissions === null || permissions === void 0 ? void 0 : permissions.length)) {
|
|
74
|
+
context.logger.out(`Auth: No Permission stated for route ${(_a = context === null || context === void 0 ? void 0 : context.request) === null || _a === void 0 ? void 0 : _a.method} ${(_b = context === null || context === void 0 ? void 0 : context.request) === null || _b === void 0 ? void 0 : _b.url}`);
|
|
75
|
+
return { data: context };
|
|
76
|
+
}
|
|
77
|
+
context.logger.out(`=================== middleware authorizing ${context.request.method} request to ${context.request.url} =============`);
|
|
78
|
+
const { data } = yield _axios.post("/v1/auths/validate-user-permission", {
|
|
79
|
+
ip: req.ip,
|
|
80
|
+
requestClient: req.headers["request-client"],
|
|
81
|
+
contextClient: req.headers["context-client"],
|
|
82
|
+
requestClientId: req.headers["request-client-id"],
|
|
83
|
+
contextClientId: req.headers["context-client-id"],
|
|
84
|
+
authenticationType: req.headers["authentication-type"],
|
|
85
|
+
supportedAuthenticationType,
|
|
86
|
+
permission: permissions === null || permissions === void 0 ? void 0 : permissions[0],
|
|
87
|
+
requestUser: req.headers["request-user"],
|
|
88
|
+
contextUser: req.headers["context-user"],
|
|
89
|
+
permissions: req.headers["permissions"],
|
|
90
|
+
});
|
|
91
|
+
context = Object.assign(Object.assign({}, context), data.data);
|
|
92
|
+
if (!data.data.enforceOwn)
|
|
93
|
+
return { data: context };
|
|
94
|
+
context.data = Object.assign(Object.assign({}, context.data), { clientId: context.requestClientId, userId: context.contextUserId || (context === null || context === void 0 ? void 0 : context.requestUserId) || ((_c = context === null || context === void 0 ? void 0 : context.requestUser) === null || _c === void 0 ? void 0 : _c.userId) });
|
|
95
|
+
(_d = context.logger) === null || _d === void 0 ? void 0 : _d.setProps({
|
|
96
|
+
userId: (_e = context === null || context === void 0 ? void 0 : context.data) === null || _e === void 0 ? void 0 : _e.userId
|
|
97
|
+
});
|
|
98
|
+
return { data: context };
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
logger_1.logger.exception(e);
|
|
102
|
+
logger_1.logger.out(`Auth: error authorizing request: `, e, e.message, (_f = e === null || e === void 0 ? void 0 : e.response) === null || _f === void 0 ? void 0 : _f.data);
|
|
103
|
+
return { error: ((_h = (_g = e === null || e === void 0 ? void 0 : e.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.error) || "You are not authorized to access this resource!!!" };
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.getContext = getContext;
|
|
108
|
+
function unless(middlewareName, paths, middleware) {
|
|
109
|
+
if (!middleware)
|
|
110
|
+
return;
|
|
111
|
+
if (!paths.length)
|
|
112
|
+
return;
|
|
113
|
+
const pathsAsRegex = paths.map(path => (0, path_to_regexp_1.pathToRegexp)(path));
|
|
114
|
+
return function (req, res, next) {
|
|
115
|
+
for (let path of pathsAsRegex) {
|
|
116
|
+
if (path.test(req.path)) {
|
|
117
|
+
logger_1.logger.debug(`unless: skipping middleware "${middlewareName}" for path "${req.path}"`);
|
|
118
|
+
return next();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return middleware(req, res, next);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
exports.unless = unless;
|
|
125
|
+
const apitoolkitMiddleware = (config = {}) => {
|
|
126
|
+
config.apiKey = config.apiKey || process.env.API_TOOLKIT_API_KEY;
|
|
127
|
+
config.env = config.env || process.env.NODE_ENV || "unknown";
|
|
128
|
+
config.excludePaths = [...(config.excludePaths || []), "/health-check", "/cron/*", "/metrics"];
|
|
129
|
+
config.tags = [...(config.tags || []), config.env];
|
|
130
|
+
config.redactRequestBody = [...(config.redactRequestBody || []), "password", "client-secret"];
|
|
131
|
+
config.redactResponseBody = [...(config.redactResponseBody || []), "$.data.secret"];
|
|
132
|
+
const apitoolkitConfig = Object.assign(Object.assign({}, config.rawApiToolkitConfig), { apiKey: config.apiKey, redactHeaders: config.redactHeaders, redactRequestBody: config.redactRequestBody, redactResponseBody: config.redactResponseBody, tags: config.tags, serviceVersion: config.serviceVersion, debug: config.debug });
|
|
133
|
+
if (!config.apiKey) {
|
|
134
|
+
logger_1.logger.debug("APIToolkit API Key Not Present");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const apitoolkitClient = apitoolkit_express_1.default.NewClient(apitoolkitConfig);
|
|
138
|
+
return unless("api-toolkit", config.excludePaths || [], apitoolkitClient.expressMiddleware);
|
|
139
|
+
};
|
|
140
|
+
exports.apitoolkitMiddleware = apitoolkitMiddleware;
|
|
141
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CAAC,kBAAkB,IAAI,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC;IAErF,MAAM,gBAAgB,mCACf,MAAM,CAAC,mBAAmB,KAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAC3C,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAC7C,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,cAAc,EAAE,MAAM,CAAC,cAAc,EACrC,KAAK,EAAE,MAAM,CAAC,KAAK,GACtB,CAAC;IAGF,IAAG,CAAC,MAAM,CAAC,MAAM,EAAC,CAAC;QACf,eAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAChD,OAAO;IACX,CAAC;IAED,MAAM,gBAAgB,GAAG,4BAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEhE,OAAO,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAChG,CAAC,CAAA;AA9BY,QAAA,oBAAoB,wBA8BhC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Response, Request, NextFunction } from "express";
|
|
2
|
+
export declare function internalOnly(req: Request, res: Response, next: NextFunction): void | Promise<Response<any, Record<string, any>>>;
|
|
3
|
+
export declare const can: (supportedAuthenticationType: string[], permissions: string[], options?: any) => (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
4
|
+
export declare const registerLogger: (req: Request, res: Response, next: NextFunction) => void;
|