exodus-framework 2.0.756 → 2.0.757
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/app/app.js +84 -0
- package/lib/app/controller.js +95 -0
- package/lib/app/core.js +71 -0
- package/lib/app/error.js +66 -0
- package/lib/app/index.js +72 -0
- package/lib/app/service.js +24 -0
- package/lib/app/settings.js +138 -0
- package/lib/app/singleton.js +29 -0
- package/lib/contracts/console.js +5 -0
- package/lib/contracts/entity.js +5 -0
- package/lib/contracts/http.js +50 -0
- package/lib/contracts/index.js +104 -0
- package/lib/contracts/messaging.js +25 -0
- package/lib/contracts/security.js +5 -0
- package/lib/contracts/service.js +5 -0
- package/lib/contracts/session.js +5 -0
- package/lib/contracts/settings.js +5 -0
- package/lib/contracts/singleton.js +5 -0
- package/lib/contracts/socket.js +11 -0
- package/lib/controllers/api/file.js +24 -0
- package/lib/controllers/api/index.js +13 -0
- package/lib/controllers/index.js +16 -0
- package/lib/controllers/messaging/application.js +63 -0
- package/lib/controllers/messaging/database.js +63 -0
- package/lib/controllers/messaging/environment.js +100 -0
- package/lib/express.d.js +5 -0
- package/lib/index.js +92 -0
- package/lib/middlewares/access.js +77 -0
- package/lib/middlewares/authentication.js +21 -0
- package/lib/middlewares/file.js +41 -0
- package/lib/middlewares/index.js +27 -0
- package/lib/models/Application.js +61 -0
- package/lib/models/DatabaseHost.js +62 -0
- package/lib/models/EnvConnection.js +41 -0
- package/lib/models/index.js +46 -0
- package/lib/routes/index.js +16 -0
- package/lib/routes/messaging/index.js +34 -0
- package/lib/services/express.js +151 -0
- package/lib/services/file.js +65 -0
- package/lib/services/index.d.ts +0 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +76 -0
- package/lib/services/rabitmq.js +101 -0
- package/lib/services/redis.js +62 -0
- package/lib/services/security.js +229 -0
- package/lib/services/sequelize.js +285 -0
- package/lib/services/socket.js +55 -0
- package/lib/services/task.js +164 -0
- package/lib/utils/api.js +50 -0
- package/lib/utils/database.js +158 -0
- package/lib/utils/date.js +28 -0
- package/lib/utils/index.js +60 -0
- package/lib/utils/logger.js +51 -0
- package/lib/utils/session.js +23 -0
- package/package.json +1 -1
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
var _controller = require("../app/controller");
|
8
|
+
var _service = _interopRequireDefault(require("../app/service"));
|
9
|
+
var _socket = require("socket.io");
|
10
|
+
var _express = _interopRequireDefault(require("./express"));
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
|
+
/**
|
13
|
+
* Serviço de gerênciamento de comunicação WS/WSS Socket
|
14
|
+
*
|
15
|
+
* @class SocketIOService
|
16
|
+
* @extends {Service}
|
17
|
+
* @implements {IService}
|
18
|
+
*/
|
19
|
+
class SocketIOService extends _service.default {
|
20
|
+
server;
|
21
|
+
mainRouter;
|
22
|
+
constructor() {
|
23
|
+
super();
|
24
|
+
}
|
25
|
+
async init() {
|
26
|
+
if (!this.mainRouter) throw new Error('Need router'); //!sem router
|
27
|
+
const server = _express.default.singleton().getHttpServer();
|
28
|
+
this.createSocket(server);
|
29
|
+
this.server.on('connection', this.onConnection.bind(this));
|
30
|
+
this.log('Socket server created');
|
31
|
+
}
|
32
|
+
onConnection(socket) {
|
33
|
+
this.log(`${socket.id} conectado`);
|
34
|
+
socket.on('disconnect', () => this.log(`${socket.id} desconectado`));
|
35
|
+
this.bindEvents(socket);
|
36
|
+
}
|
37
|
+
bindEvents(socket) {
|
38
|
+
Object.entries(this.mainRouter).forEach(([key, handle]) => {
|
39
|
+
socket.on(key, (...args) => {
|
40
|
+
handle(new _controller.SocketRequest(socket, key), ...args);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
}
|
44
|
+
createSocket(app, cors = {
|
45
|
+
origin: '*'
|
46
|
+
}) {
|
47
|
+
this.server = new _socket.Server(app, {
|
48
|
+
cors
|
49
|
+
});
|
50
|
+
}
|
51
|
+
registerRouter(router) {
|
52
|
+
this.mainRouter = router;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
var _default = exports.default = SocketIOService;
|
@@ -0,0 +1,164 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TaskSchedulingService = exports.TaskQueueService = exports.SchedulingTask = exports.QueueTask = void 0;
|
7
|
+
var _bullmq = require("bullmq");
|
8
|
+
var _fs = require("fs");
|
9
|
+
var _nodeSchedule = require("node-schedule");
|
10
|
+
var _service = _interopRequireDefault(require("../app/service"));
|
11
|
+
var _singleton = _interopRequireDefault(require("../app/singleton"));
|
12
|
+
var _app = require("../app");
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
|
+
//* Base
|
15
|
+
class TaskServiceBase extends _service.default {
|
16
|
+
jobsPath;
|
17
|
+
setTaskPath(path) {
|
18
|
+
this.jobsPath = path;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
//* Scheduler
|
23
|
+
class TaskSchedulingService extends TaskServiceBase {
|
24
|
+
jobs;
|
25
|
+
async init() {
|
26
|
+
if (!this.jobsPath) {
|
27
|
+
return this.log('Tasks file path not found!', 'danger');
|
28
|
+
}
|
29
|
+
this.jobs = [];
|
30
|
+
this.log('Initializing jobs...', 'info');
|
31
|
+
await this.importAllJobs();
|
32
|
+
await this.processAllJobs();
|
33
|
+
this.log('All jobs initializeds...', 'info');
|
34
|
+
}
|
35
|
+
async registerJob(job) {
|
36
|
+
this.jobs.push(job);
|
37
|
+
}
|
38
|
+
async importAllJobs() {
|
39
|
+
if (!(0, _fs.existsSync)(this.jobsPath)) (0, _fs.mkdirSync)(this.jobsPath, {
|
40
|
+
recursive: true
|
41
|
+
});
|
42
|
+
for (const handlerFile of (0, _fs.readdirSync)(this.jobsPath)) {
|
43
|
+
try {
|
44
|
+
const job = require(`${this.jobsPath}/${handlerFile}`).default;
|
45
|
+
const jobInstance = job.singleton();
|
46
|
+
this.jobs.push(jobInstance);
|
47
|
+
} catch (error) {
|
48
|
+
new _app.ErrorHandler(`Falha ao iniciar um ou mais jobs: ${handlerFile}`, error);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
async processAllJobs() {
|
53
|
+
for (const job of this.jobs) {
|
54
|
+
if (!job.getActive()) continue;
|
55
|
+
(0, _nodeSchedule.scheduleJob)(job.getJobTime(), job.handler.bind(job));
|
56
|
+
this.log(`Job '${job.getJobName()}' started...`, 'warning');
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
exports.TaskSchedulingService = TaskSchedulingService;
|
61
|
+
class SchedulingTask extends _singleton.default {
|
62
|
+
getJobTime() {
|
63
|
+
return this.cron;
|
64
|
+
}
|
65
|
+
getActive() {
|
66
|
+
return this.active;
|
67
|
+
}
|
68
|
+
getJobName() {
|
69
|
+
return this.name;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
//* Queue
|
74
|
+
exports.SchedulingTask = SchedulingTask;
|
75
|
+
class TaskQueueService extends TaskServiceBase {
|
76
|
+
jobs;
|
77
|
+
connection;
|
78
|
+
async init() {
|
79
|
+
this.jobs = [];
|
80
|
+
this.connection = {
|
81
|
+
host: _app.Core.settings.getCache().host,
|
82
|
+
port: Number(_app.Core.settings.getCache().port),
|
83
|
+
password: _app.Core.settings.getCache().password
|
84
|
+
};
|
85
|
+
this.log('Initializing jobs...', 'info');
|
86
|
+
await this.importAllJobs();
|
87
|
+
await this.processAllJobs();
|
88
|
+
this.log('All jobs initializeds...', 'info');
|
89
|
+
}
|
90
|
+
async registerJob(job) {
|
91
|
+
this.jobs.push(job);
|
92
|
+
}
|
93
|
+
async importAllJobs() {
|
94
|
+
if (!(0, _fs.existsSync)(this.jobsPath)) (0, _fs.mkdirSync)(this.jobsPath, {
|
95
|
+
recursive: true
|
96
|
+
});
|
97
|
+
for (const handlerFile of (0, _fs.readdirSync)(this.jobsPath)) {
|
98
|
+
const job = require(`${this.jobsPath}/${handlerFile}`).default;
|
99
|
+
const jobInstance = job.singleton();
|
100
|
+
this.jobs.push(jobInstance);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
async processAllJobs() {
|
104
|
+
for (const job of this.jobs) {
|
105
|
+
this.startTask(job);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
async startTask(task) {
|
109
|
+
if (!task.getActive()) return;
|
110
|
+
const queue = new _bullmq.Queue(task.getQueueName(), {
|
111
|
+
connection: this.connection
|
112
|
+
});
|
113
|
+
const worker = new _bullmq.Worker(task.getQueueName(), task.handle.bind(task), {
|
114
|
+
connection: this.connection
|
115
|
+
});
|
116
|
+
task.setQueue(queue);
|
117
|
+
task.setWorker(worker);
|
118
|
+
task.init();
|
119
|
+
this.log(`Job '${task.getQueueName()}' started...`, 'warning');
|
120
|
+
}
|
121
|
+
}
|
122
|
+
exports.TaskQueueService = TaskQueueService;
|
123
|
+
class QueueTask extends _singleton.default {
|
124
|
+
queue;
|
125
|
+
worker;
|
126
|
+
initialize() {
|
127
|
+
this.queue = new _bullmq.Queue(this.getQueueName(), {
|
128
|
+
// Configurações do Redis
|
129
|
+
connection: {
|
130
|
+
host: 'localhost',
|
131
|
+
port: 6379
|
132
|
+
}
|
133
|
+
});
|
134
|
+
this.worker = new _bullmq.Worker(this.getQueueName(), this.handle.bind(this), {
|
135
|
+
connection: {
|
136
|
+
host: 'localhost',
|
137
|
+
port: 6379
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
async addJob(data) {
|
142
|
+
await this.queue.add(this.getQueueName(), data);
|
143
|
+
this.log('Nova tarefa disponível.', 'comment');
|
144
|
+
}
|
145
|
+
getQueue() {
|
146
|
+
return this.queue;
|
147
|
+
}
|
148
|
+
setQueue(queue) {
|
149
|
+
this.queue = queue;
|
150
|
+
}
|
151
|
+
getWorker() {
|
152
|
+
return this.worker;
|
153
|
+
}
|
154
|
+
setWorker(worker) {
|
155
|
+
this.worker = worker;
|
156
|
+
}
|
157
|
+
getActive() {
|
158
|
+
return this.active;
|
159
|
+
}
|
160
|
+
getQueueName() {
|
161
|
+
return this.queueName;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
exports.QueueTask = QueueTask;
|
package/lib/utils/api.js
ADDED
@@ -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 _axios = _interopRequireDefault(require("axios"));
|
9
|
+
var _dateFns = require("date-fns");
|
10
|
+
var _app = require("../app");
|
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 _app.ErrorHandler('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,158 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.masterDB = void 0;
|
7
|
+
exports.processFilters = processFilters;
|
8
|
+
exports.serviceDB = void 0;
|
9
|
+
var _sequelize = require("sequelize");
|
10
|
+
var _app = require("../app");
|
11
|
+
var _logger = _interopRequireDefault(require("./logger"));
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
|
+
const serviceDB = exports.serviceDB = new _sequelize.Sequelize({
|
14
|
+
database: _app.Core.settings.getDatabase().service.database,
|
15
|
+
dialect: _app.Core.settings.getDatabase().master.dialect,
|
16
|
+
username: _app.Core.settings.getDatabase().master.username,
|
17
|
+
password: _app.Core.settings.getDatabase().master.password,
|
18
|
+
define: {
|
19
|
+
timestamps: true
|
20
|
+
},
|
21
|
+
timezone: '-03:00',
|
22
|
+
logging(sql, timing) {
|
23
|
+
(0, _logger.default)().trace('DATABASE', sql, timing);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
const masterDB = exports.masterDB = new _sequelize.Sequelize({
|
27
|
+
database: _app.Core.settings.getDatabase().master.database,
|
28
|
+
dialect: _app.Core.settings.getDatabase().master.dialect,
|
29
|
+
username: _app.Core.settings.getDatabase().master.username,
|
30
|
+
password: _app.Core.settings.getDatabase().master.password,
|
31
|
+
define: {
|
32
|
+
timestamps: true
|
33
|
+
},
|
34
|
+
timezone: '-03:00',
|
35
|
+
logging(sql, timing) {
|
36
|
+
(0, _logger.default)().trace('DATABASE', sql, timing);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
function processCondition(cond) {
|
40
|
+
if ('or' in cond) {
|
41
|
+
return {
|
42
|
+
[_sequelize.Op.or]: cond.or.map(subCond => processCondition(subCond))
|
43
|
+
};
|
44
|
+
}
|
45
|
+
if ('and' in cond) {
|
46
|
+
return {
|
47
|
+
[_sequelize.Op.and]: cond.and.map(subCond => processCondition(subCond))
|
48
|
+
};
|
49
|
+
}
|
50
|
+
const simpleWhere = {};
|
51
|
+
if (cond.eq !== undefined) {
|
52
|
+
simpleWhere[_sequelize.Op.eq] = cond.type === 'DATE' ? new Date(cond.eq) : cond.eq;
|
53
|
+
}
|
54
|
+
if (cond.gt !== undefined) {
|
55
|
+
simpleWhere[_sequelize.Op.gt] = cond.type === 'DATE' ? new Date(cond.eq) : cond.gt;
|
56
|
+
}
|
57
|
+
if (cond.lt !== undefined) {
|
58
|
+
simpleWhere[_sequelize.Op.lt] = cond.type === 'DATE' ? new Date(cond.lt) : cond.lt;
|
59
|
+
}
|
60
|
+
if (cond.between !== undefined) {
|
61
|
+
simpleWhere[_sequelize.Op.between] = cond.type === 'DATE' ? cond.between.map(d => new Date(d)) : cond.between;
|
62
|
+
}
|
63
|
+
if (cond.notBetween !== undefined) {
|
64
|
+
simpleWhere[_sequelize.Op.notBetween] = cond.type === 'DATE' ? cond.notBetween.map(d => new Date(d)) : cond.notBetween;
|
65
|
+
}
|
66
|
+
if (cond.like !== undefined) {
|
67
|
+
simpleWhere[_sequelize.Op.like] = cond.type === 'DATE' ? new Date(cond.like) : cond.like;
|
68
|
+
}
|
69
|
+
if (cond.notLike !== undefined) {
|
70
|
+
simpleWhere[_sequelize.Op.notLike] = cond.type === 'DATE' ? new Date(cond.notLike) : cond.notLike;
|
71
|
+
}
|
72
|
+
if (cond.in !== undefined) {
|
73
|
+
simpleWhere[_sequelize.Op.in] = cond.type === 'DATE' ? cond.in.map(d => new Date(d)) : cond.in;
|
74
|
+
}
|
75
|
+
if (cond.notIn !== undefined) {
|
76
|
+
simpleWhere[_sequelize.Op.notIn] = cond.type === 'DATE' ? cond.notIn.map(d => new Date(d)) : cond.notIn;
|
77
|
+
}
|
78
|
+
return simpleWhere;
|
79
|
+
}
|
80
|
+
function processDateCondition(key, cond) {
|
81
|
+
const simpleWhere = [key, undefined];
|
82
|
+
if (cond.eq !== undefined) {
|
83
|
+
simpleWhere[0] = _sequelize.Op.and;
|
84
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) = '${cond.eq}'`)];
|
85
|
+
}
|
86
|
+
if (cond.gt !== undefined) {
|
87
|
+
simpleWhere[0] = _sequelize.Op.and;
|
88
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) > '${cond.gt}'`)];
|
89
|
+
}
|
90
|
+
if (cond.lt !== undefined) {
|
91
|
+
simpleWhere[0] = _sequelize.Op.and;
|
92
|
+
simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) < '${cond.lt}'`)];
|
93
|
+
}
|
94
|
+
if (cond.between !== undefined) {
|
95
|
+
simpleWhere[1] = {
|
96
|
+
[_sequelize.Op.between]: cond.between.map(d => new Date(d))
|
97
|
+
};
|
98
|
+
}
|
99
|
+
if (cond.notBetween !== undefined) {
|
100
|
+
simpleWhere[1] = {
|
101
|
+
[_sequelize.Op.notBetween]: cond.notBetween.map(d => new Date(d))
|
102
|
+
};
|
103
|
+
}
|
104
|
+
if (cond.in !== undefined) {
|
105
|
+
simpleWhere[1] = {
|
106
|
+
[_sequelize.Op.in]: cond.in.map(d => new Date(d))
|
107
|
+
};
|
108
|
+
}
|
109
|
+
if (cond.notIn !== undefined) {
|
110
|
+
simpleWhere[1] = {
|
111
|
+
[_sequelize.Op.notIn]: cond.notIn.map(d => new Date(d))
|
112
|
+
};
|
113
|
+
}
|
114
|
+
return simpleWhere;
|
115
|
+
}
|
116
|
+
|
117
|
+
// Função Principal para Processar Filtros
|
118
|
+
function processFilters(filters) {
|
119
|
+
if (!filters) return {};
|
120
|
+
const where = {};
|
121
|
+
Object.entries(filters).forEach(([key, condition]) => {
|
122
|
+
if (key === 'or' || key === 'and') {
|
123
|
+
const logicalOp = key === 'or' ? _sequelize.Op.or : _sequelize.Op.and;
|
124
|
+
const t = [];
|
125
|
+
for (const c of condition) {
|
126
|
+
const [[key, value]] = Object.entries(c);
|
127
|
+
t.push({
|
128
|
+
[key]: processCondition(value)
|
129
|
+
});
|
130
|
+
}
|
131
|
+
if (!where[logicalOp]) {
|
132
|
+
where[logicalOp] = [];
|
133
|
+
}
|
134
|
+
where[logicalOp].push(...t);
|
135
|
+
} else {
|
136
|
+
const field = key;
|
137
|
+
const isDate = condition.type && condition.type === 'DATE';
|
138
|
+
// const isTime = condition.type && condition.type === 'TIME';
|
139
|
+
// const isDateTime = condition.type && condition.type === 'DATETIME';
|
140
|
+
|
141
|
+
if (isDate) {
|
142
|
+
const [k, c] = processDateCondition(key, condition);
|
143
|
+
where[k] = c;
|
144
|
+
} else {
|
145
|
+
const processedCondition = processCondition(condition);
|
146
|
+
if (where[field]) {
|
147
|
+
where[field] = {
|
148
|
+
...where[field],
|
149
|
+
...processedCondition
|
150
|
+
};
|
151
|
+
} else {
|
152
|
+
where[field] = processedCondition;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
});
|
157
|
+
return where;
|
158
|
+
}
|
@@ -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
|
+
}
|
@@ -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,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
var _dateFns = require("date-fns");
|
8
|
+
var _fs = require("fs");
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
10
|
+
var _pinoMultiStream = _interopRequireDefault(require("pino-multi-stream"));
|
11
|
+
var _app = require("../app");
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
|
+
let loggerInstance = null;
|
14
|
+
const createLogger = () => {
|
15
|
+
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'));
|
16
|
+
(0, _fs.mkdirSync)(basePath, {
|
17
|
+
recursive: true
|
18
|
+
});
|
19
|
+
const streams = [{
|
20
|
+
level: 'error',
|
21
|
+
stream: (0, _fs.createWriteStream)(basePath + '/error' + _app.Core.settings.getLogger().fileformat)
|
22
|
+
}, {
|
23
|
+
level: 'info',
|
24
|
+
stream: (0, _fs.createWriteStream)(basePath + '/info' + _app.Core.settings.getLogger().fileformat)
|
25
|
+
}, {
|
26
|
+
level: 'fatal',
|
27
|
+
stream: (0, _fs.createWriteStream)(basePath + '/fatal' + _app.Core.settings.getLogger().fileformat)
|
28
|
+
}, {
|
29
|
+
level: 'warn',
|
30
|
+
stream: (0, _fs.createWriteStream)(basePath + '/warn' + _app.Core.settings.getLogger().fileformat)
|
31
|
+
}, {
|
32
|
+
level: 'silent',
|
33
|
+
stream: (0, _fs.createWriteStream)(basePath + '/silent' + _app.Core.settings.getLogger().fileformat)
|
34
|
+
}, {
|
35
|
+
level: 'trace',
|
36
|
+
stream: (0, _fs.createWriteStream)(basePath + '/trace' + _app.Core.settings.getLogger().fileformat)
|
37
|
+
}];
|
38
|
+
_app.Core.settings.getLogger().console ?? streams.push({
|
39
|
+
stream: process.stdout
|
40
|
+
});
|
41
|
+
return (0, _pinoMultiStream.default)({
|
42
|
+
streams
|
43
|
+
});
|
44
|
+
};
|
45
|
+
const logger = () => {
|
46
|
+
if (!loggerInstance) {
|
47
|
+
loggerInstance = createLogger();
|
48
|
+
}
|
49
|
+
return loggerInstance;
|
50
|
+
};
|
51
|
+
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;
|