exodus-framework 2.0.699 → 2.0.700

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.
Files changed (56) hide show
  1. package/lib/app/app.js +84 -0
  2. package/lib/app/controller.js +95 -0
  3. package/lib/app/core.js +66 -0
  4. package/lib/app/index.js +60 -0
  5. package/lib/app/service.js +24 -0
  6. package/lib/app/settings.js +135 -0
  7. package/lib/app/singleton.js +29 -0
  8. package/lib/contracts/console.js +5 -0
  9. package/lib/contracts/entity.js +5 -0
  10. package/lib/contracts/http.js +50 -0
  11. package/lib/contracts/index.js +104 -0
  12. package/lib/contracts/messaging.js +18 -0
  13. package/lib/contracts/security.js +5 -0
  14. package/lib/contracts/service.js +5 -0
  15. package/lib/contracts/session.js +5 -0
  16. package/lib/contracts/settings.js +5 -0
  17. package/lib/contracts/singleton.js +5 -0
  18. package/lib/contracts/socket.js +11 -0
  19. package/lib/controllers/api/file.js +24 -0
  20. package/lib/controllers/api/index.js +13 -0
  21. package/lib/controllers/index.js +16 -0
  22. package/lib/controllers/messaging/database.js +53 -0
  23. package/lib/controllers/messaging/environment.js +70 -0
  24. package/lib/express.d.js +5 -0
  25. package/lib/index.js +92 -0
  26. package/lib/middlewares/access.js +63 -0
  27. package/lib/middlewares/authentication.js +21 -0
  28. package/lib/middlewares/file.js +41 -0
  29. package/lib/middlewares/index.js +27 -0
  30. package/lib/models/Application.js +61 -0
  31. package/lib/models/Connection.js +54 -0
  32. package/lib/models/EnvConnection.js +41 -0
  33. package/lib/models/index.js +46 -0
  34. package/lib/routes/index.js +16 -0
  35. package/lib/routes/messaging/index.js +26 -0
  36. package/lib/services/error.js +49 -0
  37. package/lib/services/express.js +140 -0
  38. package/lib/services/file.js +65 -0
  39. package/lib/services/index.d.ts +1 -0
  40. package/lib/services/index.d.ts.map +1 -1
  41. package/lib/services/index.js +88 -0
  42. package/lib/services/rabitmq.js +93 -0
  43. package/lib/services/redis.js +60 -0
  44. package/lib/services/security.js +224 -0
  45. package/lib/services/sequelize.js +242 -0
  46. package/lib/services/socket.js +56 -0
  47. package/lib/services/task.js +162 -0
  48. package/lib/utils/api.js +50 -0
  49. package/lib/utils/database.js +36 -0
  50. package/lib/utils/date.js +28 -0
  51. package/lib/utils/index.d.ts +0 -1
  52. package/lib/utils/index.d.ts.map +1 -1
  53. package/lib/utils/index.js +60 -0
  54. package/lib/utils/logger.js +55 -0
  55. package/lib/utils/session.js +23 -0
  56. package/package.json +1 -1
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _core = _interopRequireDefault(require("../app/core"));
8
+ var _error = require("../services/error");
9
+ var _axios = _interopRequireDefault(require("axios"));
10
+ var _dateFns = require("date-fns");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ class Api extends _core.default {
13
+ axios;
14
+ constructor() {
15
+ super();
16
+ this.init();
17
+ }
18
+ async init() {
19
+ this.axios = _axios.default.create({
20
+ baseURL: this.host,
21
+ headers: {
22
+ ...this.headers,
23
+ 'Content-Type': 'application/json'
24
+ },
25
+ validateStatus: this.validateStatus
26
+ });
27
+ }
28
+ async request(endpoint, method, data, params, headers) {
29
+ try {
30
+ const res = await this.axios({
31
+ method,
32
+ url: this.host + endpoint,
33
+ data,
34
+ params,
35
+ headers: {
36
+ ...headers,
37
+ ...this.headers
38
+ }
39
+ });
40
+ return res.data;
41
+ } catch (error) {
42
+ new _error.ApplicationException('não foi possível realizar uma requisição', error);
43
+ }
44
+ }
45
+ getLogicalSecurityId() {
46
+ const date = (0, _dateFns.format)(new Date(), 'yyyy-MM-dd');
47
+ return String(Date.parse(date) - 5000);
48
+ }
49
+ }
50
+ var _default = exports.default = Api;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.serviceDB = exports.masterDB = void 0;
7
+ var _sequelize = require("sequelize");
8
+ var _logger = _interopRequireDefault(require("./logger"));
9
+ var _app = require("../app");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const serviceDB = exports.serviceDB = new _sequelize.Sequelize({
12
+ database: _app.Core.settings.getDatabase().service.database,
13
+ dialect: _app.Core.settings.getDatabase().master.dialect,
14
+ username: _app.Core.settings.getDatabase().master.username,
15
+ password: _app.Core.settings.getDatabase().master.password,
16
+ define: {
17
+ timestamps: true
18
+ },
19
+ timezone: '-03:00',
20
+ logging(sql, timing) {
21
+ (0, _logger.default)().trace('DATABASE', sql, timing);
22
+ }
23
+ });
24
+ const masterDB = exports.masterDB = new _sequelize.Sequelize({
25
+ database: _app.Core.settings.getDatabase().master.database,
26
+ dialect: _app.Core.settings.getDatabase().master.dialect,
27
+ username: _app.Core.settings.getDatabase().master.username,
28
+ password: _app.Core.settings.getDatabase().master.password,
29
+ define: {
30
+ timestamps: true
31
+ },
32
+ timezone: '-03:00',
33
+ logging(sql, timing) {
34
+ (0, _logger.default)().trace('DATABASE', sql, timing);
35
+ }
36
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.timestampDifference = timestampDifference;
7
+ function timestampDifference(timestamp1, timestamp2, type = 'd') {
8
+ const difference = timestamp1 - timestamp2;
9
+ let dvrs;
10
+ switch (type) {
11
+ case 'd':
12
+ dvrs = difference / 1000 / 60 / 60 / 24;
13
+ break;
14
+ case 'h':
15
+ dvrs = difference / 1000 / 60 / 60;
16
+ break;
17
+ case 'm':
18
+ dvrs = difference / 1000 / 60;
19
+ break;
20
+ case 's':
21
+ dvrs = difference / 1000;
22
+ break;
23
+ default:
24
+ dvrs = difference / 1000 / 60 / 60 / 24;
25
+ break;
26
+ }
27
+ return Math.round(dvrs * -1 * 100) / 100;
28
+ }
@@ -3,5 +3,4 @@ export * from './database';
3
3
  export * from './date';
4
4
  export { default as logger } from './logger';
5
5
  export * from './session';
6
- export * from './secutiry';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,WAAW,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ Api: true,
8
+ logger: true
9
+ };
10
+ Object.defineProperty(exports, "Api", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _api.default;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "logger", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _logger.default;
20
+ }
21
+ });
22
+ var _api = _interopRequireDefault(require("./api"));
23
+ var _database = require("./database");
24
+ Object.keys(_database).forEach(function (key) {
25
+ if (key === "default" || key === "__esModule") return;
26
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
+ if (key in exports && exports[key] === _database[key]) return;
28
+ Object.defineProperty(exports, key, {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _database[key];
32
+ }
33
+ });
34
+ });
35
+ var _date = require("./date");
36
+ Object.keys(_date).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _date[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _date[key];
44
+ }
45
+ });
46
+ });
47
+ var _logger = _interopRequireDefault(require("./logger"));
48
+ var _session = require("./session");
49
+ Object.keys(_session).forEach(function (key) {
50
+ if (key === "default" || key === "__esModule") return;
51
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
52
+ if (key in exports && exports[key] === _session[key]) return;
53
+ Object.defineProperty(exports, key, {
54
+ enumerable: true,
55
+ get: function () {
56
+ return _session[key];
57
+ }
58
+ });
59
+ });
60
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _fs = require("fs");
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _pino = _interopRequireDefault(require("pino"));
10
+ var _pinoMultiStream = require("pino-multi-stream");
11
+ var _app = require("../app");
12
+ var _dateFns = require("date-fns");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ let loggerInstance = null;
15
+ const createLogger = () => {
16
+ const basePath = _path.default.resolve(_app.Core.settings.getLogger().path, (0, _dateFns.format)(new Date(), 'dd-MM-yyyy'), (0, _dateFns.format)(new Date(), 'HH_mm'));
17
+ (0, _fs.mkdirSync)(basePath, {
18
+ recursive: true
19
+ });
20
+ const streams = [{
21
+ level: 'error',
22
+ stream: (0, _fs.createWriteStream)(basePath + '/error' + _app.Core.settings.getLogger().fileformat)
23
+ }, {
24
+ level: 'info',
25
+ stream: (0, _fs.createWriteStream)(basePath + '/info' + _app.Core.settings.getLogger().fileformat)
26
+ }, {
27
+ level: 'fatal',
28
+ stream: (0, _fs.createWriteStream)(basePath + '/fatal' + _app.Core.settings.getLogger().fileformat)
29
+ }, {
30
+ level: 'warn',
31
+ stream: (0, _fs.createWriteStream)(basePath + '/warn' + _app.Core.settings.getLogger().fileformat)
32
+ }, {
33
+ level: 'silent',
34
+ stream: (0, _fs.createWriteStream)(basePath + '/silent' + _app.Core.settings.getLogger().fileformat)
35
+ }, {
36
+ level: 'trace',
37
+ stream: (0, _fs.createWriteStream)(basePath + '/trace' + _app.Core.settings.getLogger().fileformat)
38
+ }];
39
+ _app.Core.settings.getLogger().console ?? streams.push({
40
+ stream: process.stdout
41
+ });
42
+ return (0, _pino.default)({
43
+ name: 'exodus',
44
+ level: _app.Core.settings.getLogger().level,
45
+ // this MUST be set at the lowest level of the
46
+ timestamp: () => `,"time":"${new Date().toJSON()}"`
47
+ }, (0, _pinoMultiStream.multistream)(streams));
48
+ };
49
+ const logger = () => {
50
+ if (!loggerInstance) {
51
+ loggerInstance = createLogger();
52
+ }
53
+ return loggerInstance;
54
+ };
55
+ var _default = exports.default = logger;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SessionAPI = void 0;
7
+ var _app = require("../app");
8
+ var _api = _interopRequireDefault(require("./api"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ class SessionAPI extends _api.default {
11
+ host = process.env.APP_SESSION_URL;
12
+ headers = {
13
+ 'X-Exodus-App-Sec': this.getLogicalSecurityId(),
14
+ 'X-Exodus-Core-Version': _app.Exodus.getVersion()
15
+ };
16
+ validateStatus(status) {
17
+ return status < 400;
18
+ }
19
+ async getCertificate() {
20
+ return this.request('/api/v1/session/certificate', 'get');
21
+ }
22
+ }
23
+ exports.SessionAPI = SessionAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.699",
3
+ "version": "2.0.700",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",