@resolveio/server-lib 12.5.54 → 12.5.55
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/client-server-app.d.ts +1 -0
- package/client-server-app.js +48 -0
- package/client-server-app.js.map +1 -0
- package/collections/app-status.collection.d.ts +3 -0
- package/collections/app-status.collection.js +51 -0
- package/collections/app-status.collection.js.map +1 -0
- package/collections/counter.collection.d.ts +3 -0
- package/collections/counter.collection.js +54 -0
- package/collections/counter.collection.js.map +1 -0
- package/collections/cron-job-history.collection.d.ts +3 -0
- package/collections/cron-job-history.collection.js +82 -0
- package/collections/cron-job-history.collection.js.map +1 -0
- package/collections/cron-job.collection.d.ts +3 -0
- package/collections/cron-job.collection.js +85 -0
- package/collections/cron-job.collection.js.map +1 -0
- package/collections/email-history.collection.d.ts +3 -0
- package/collections/email-history.collection.js +66 -0
- package/collections/email-history.collection.js.map +1 -0
- package/collections/email-verified.collection.d.ts +3 -0
- package/collections/email-verified.collection.js +61 -0
- package/collections/email-verified.collection.js.map +1 -0
- package/collections/file.collection.d.ts +3 -0
- package/collections/file.collection.js +73 -0
- package/collections/file.collection.js.map +1 -0
- package/collections/flag.collection.d.ts +3 -0
- package/collections/flag.collection.js +56 -0
- package/collections/flag.collection.js.map +1 -0
- package/collections/log-method-latency.collection.d.ts +3 -0
- package/collections/log-method-latency.collection.js +64 -0
- package/collections/log-method-latency.collection.js.map +1 -0
- package/collections/log-subscription.collection.d.ts +3 -0
- package/collections/log-subscription.collection.js +68 -0
- package/collections/log-subscription.collection.js.map +1 -0
- package/collections/log-ts.collection.d.ts +3 -0
- package/collections/log-ts.collection.js +78 -0
- package/collections/log-ts.collection.js.map +1 -0
- package/collections/log.collection.d.ts +3 -0
- package/collections/log.collection.js +77 -0
- package/collections/log.collection.js.map +1 -0
- package/collections/logged-in-users.collection.d.ts +3 -0
- package/collections/logged-in-users.collection.js +65 -0
- package/collections/logged-in-users.collection.js.map +1 -0
- package/collections/method-response.collection.d.ts +3 -0
- package/collections/method-response.collection.js +66 -0
- package/collections/method-response.collection.js.map +1 -0
- package/collections/monitor-cpu.collection.d.ts +3 -0
- package/collections/monitor-cpu.collection.js +63 -0
- package/collections/monitor-cpu.collection.js.map +1 -0
- package/collections/monitor-memory.collection.d.ts +3 -0
- package/collections/monitor-memory.collection.js +75 -0
- package/collections/monitor-memory.collection.js.map +1 -0
- package/collections/monitor-mongo.collection.d.ts +3 -0
- package/collections/monitor-mongo.collection.js +69 -0
- package/collections/monitor-mongo.collection.js.map +1 -0
- package/collections/notification.collection.d.ts +3 -0
- package/collections/notification.collection.js +51 -0
- package/collections/notification.collection.js.map +1 -0
- package/collections/report-builder-dashboard-builder.collection.d.ts +3 -0
- package/collections/report-builder-dashboard-builder.collection.js +109 -0
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -0
- package/collections/report-builder-library.collection.d.ts +3 -0
- package/collections/report-builder-library.collection.js +87 -0
- package/collections/report-builder-library.collection.js.map +1 -0
- package/collections/report-builder-report.collection.d.ts +4 -0
- package/collections/report-builder-report.collection.js +149 -0
- package/collections/report-builder-report.collection.js.map +1 -0
- package/collections/user-group.collection.d.ts +4 -0
- package/collections/user-group.collection.js +90 -0
- package/collections/user-group.collection.js.map +1 -0
- package/collections/user-guide.collection.d.ts +3 -0
- package/collections/user-guide.collection.js +57 -0
- package/collections/user-guide.collection.js.map +1 -0
- package/collections/user.collection.d.ts +4 -0
- package/collections/user.collection.js +259 -0
- package/collections/user.collection.js.map +1 -0
- package/cron/cron.d.ts +5 -0
- package/cron/cron.js +162 -0
- package/cron/cron.js.map +1 -0
- package/fixtures/cron-jobs.d.ts +1 -0
- package/fixtures/cron-jobs.js +73 -0
- package/fixtures/cron-jobs.js.map +1 -0
- package/fixtures/init.d.ts +1 -0
- package/fixtures/init.js +59 -0
- package/fixtures/init.js.map +1 -0
- package/http/auth.d.ts +2 -0
- package/http/auth.js +763 -0
- package/http/auth.js.map +1 -0
- package/http/health.d.ts +1 -0
- package/http/health.js +12 -0
- package/http/health.js.map +1 -0
- package/http/home.d.ts +2 -0
- package/http/home.js +66 -0
- package/http/home.js.map +1 -0
- package/index.d.ts +23 -0
- package/index.js +127 -0
- package/index.js.map +1 -0
- package/managers/cron.manager.d.ts +17 -0
- package/managers/cron.manager.js +242 -0
- package/managers/cron.manager.js.map +1 -0
- package/managers/method.manager.d.ts +38 -0
- package/managers/method.manager.js +595 -0
- package/managers/method.manager.js.map +1 -0
- package/managers/mongo.manager.d.ts +178 -0
- package/managers/mongo.manager.js +2221 -0
- package/managers/mongo.manager.js.map +1 -0
- package/managers/monitor.manager.d.ts +59 -0
- package/managers/monitor.manager.js +351 -0
- package/managers/monitor.manager.js.map +1 -0
- package/managers/subscription.manager.d.ts +50 -0
- package/managers/subscription.manager.js +1091 -0
- package/managers/subscription.manager.js.map +1 -0
- package/managers/subscription.performance.d.ts +1 -0
- package/{src/managers/subscription.performance.ts → managers/subscription.performance.js} +33 -68
- package/managers/subscription.performance.js.map +1 -0
- package/methods/accounts.d.ts +2 -0
- package/methods/accounts.js +274 -0
- package/methods/accounts.js.map +1 -0
- package/methods/aws.d.ts +2 -0
- package/methods/aws.js +617 -0
- package/methods/aws.js.map +1 -0
- package/methods/collections.d.ts +2 -0
- package/methods/collections.js +499 -0
- package/methods/collections.js.map +1 -0
- package/methods/counters.d.ts +2 -0
- package/methods/counters.js +122 -0
- package/methods/counters.js.map +1 -0
- package/methods/cron-jobs.d.ts +2 -0
- package/methods/cron-jobs.js +1315 -0
- package/methods/cron-jobs.js.map +1 -0
- package/methods/flags.d.ts +2 -0
- package/methods/flags.js +9 -0
- package/methods/flags.js.map +1 -0
- package/methods/logs.d.ts +2 -0
- package/methods/logs.js +371 -0
- package/methods/logs.js.map +1 -0
- package/methods/monitor.d.ts +2 -0
- package/methods/monitor.js +565 -0
- package/methods/monitor.js.map +1 -0
- package/methods/pdf.d.ts +2 -0
- package/methods/pdf.js +468 -0
- package/methods/pdf.js.map +1 -0
- package/methods/report-builder.d.ts +2 -0
- package/methods/report-builder.js +858 -0
- package/methods/report-builder.js.map +1 -0
- package/methods/support.d.ts +2 -0
- package/methods/support.js +246 -0
- package/methods/support.js.map +1 -0
- package/{src/models/app-status.model.ts → models/app-status.model.d.ts} +2 -3
- package/models/app-status.model.js +4 -0
- package/models/app-status.model.js.map +1 -0
- package/{src/models/billing-logged-in-users.model.ts → models/billing-logged-in-users.model.d.ts} +4 -5
- package/models/billing-logged-in-users.model.js +4 -0
- package/models/billing-logged-in-users.model.js.map +1 -0
- package/models/collection-document.model.d.ts +19 -0
- package/models/collection-document.model.js +4 -0
- package/models/collection-document.model.js.map +1 -0
- package/{src/models/counter.model.ts → models/counter.model.d.ts} +3 -4
- package/models/counter.model.js +4 -0
- package/models/counter.model.js.map +1 -0
- package/models/cron-job-history.model.d.ts +12 -0
- package/models/cron-job-history.model.js +4 -0
- package/models/cron-job-history.model.js.map +1 -0
- package/models/cron-job.model.d.ts +13 -0
- package/models/cron-job.model.js +4 -0
- package/models/cron-job.model.js.map +1 -0
- package/models/dialog.model.d.ts +23 -0
- package/models/dialog.model.js +4 -0
- package/models/dialog.model.js.map +1 -0
- package/{src/models/email-history.model.ts → models/email-history.model.d.ts} +7 -8
- package/models/email-history.model.js +4 -0
- package/models/email-history.model.js.map +1 -0
- package/{src/models/email-verified.model.ts → models/email-verified.model.d.ts} +5 -6
- package/models/email-verified.model.js +4 -0
- package/models/email-verified.model.js.map +1 -0
- package/{src/models/file.model.ts → models/file.model.d.ts} +7 -8
- package/models/file.model.js +4 -0
- package/models/file.model.js.map +1 -0
- package/{src/models/flag.model.ts → models/flag.model.d.ts} +3 -4
- package/models/flag.model.js +4 -0
- package/models/flag.model.js.map +1 -0
- package/{src/models/log-method-latency.model.ts → models/log-method-latency.model.d.ts} +4 -5
- package/models/log-method-latency.model.js +4 -0
- package/models/log-method-latency.model.js.map +1 -0
- package/{src/models/log-subscription.model.ts → models/log-subscription.model.d.ts} +6 -8
- package/models/log-subscription.model.js +4 -0
- package/models/log-subscription.model.js.map +1 -0
- package/{src/models/log.model.ts → models/log.model.d.ts} +10 -12
- package/models/log.model.js +4 -0
- package/models/log.model.js.map +1 -0
- package/{src/models/logged-in-users.model.ts → models/logged-in-users.model.d.ts} +5 -6
- package/models/logged-in-users.model.js +4 -0
- package/models/logged-in-users.model.js.map +1 -0
- package/{src/models/method-response.model.ts → models/method-response.model.d.ts} +6 -7
- package/models/method-response.model.js +4 -0
- package/models/method-response.model.js.map +1 -0
- package/models/method.model.d.ts +9 -0
- package/models/method.model.js +4 -0
- package/models/method.model.js.map +1 -0
- package/{src/models/monitor-cpu.model.ts → models/monitor-cpu.model.d.ts} +7 -9
- package/models/monitor-cpu.model.js +4 -0
- package/models/monitor-cpu.model.js.map +1 -0
- package/models/monitor-memory.model.d.ts +15 -0
- package/models/monitor-memory.model.js +4 -0
- package/models/monitor-memory.model.js.map +1 -0
- package/models/monitor-mongo.model.d.ts +13 -0
- package/models/monitor-mongo.model.js +4 -0
- package/models/monitor-mongo.model.js.map +1 -0
- package/{src/models/notification.model.ts → models/notification.model.d.ts} +2 -3
- package/models/notification.model.js +4 -0
- package/models/notification.model.js.map +1 -0
- package/models/pagination.model.d.ts +10 -0
- package/models/pagination.model.js +24 -0
- package/models/pagination.model.js.map +1 -0
- package/models/permission.model.d.ts +12 -0
- package/models/permission.model.js +4 -0
- package/models/permission.model.js.map +1 -0
- package/models/report-builder-dashboard-builder.model.d.ts +25 -0
- package/models/report-builder-dashboard-builder.model.js +4 -0
- package/models/report-builder-dashboard-builder.model.js.map +1 -0
- package/models/report-builder-library.model.d.ts +17 -0
- package/models/report-builder-library.model.js +4 -0
- package/models/report-builder-library.model.js.map +1 -0
- package/models/report-builder-report.model.d.ts +98 -0
- package/models/report-builder-report.model.js +4 -0
- package/models/report-builder-report.model.js.map +1 -0
- package/models/report-builder.model.d.ts +61 -0
- package/models/report-builder.model.js +4 -0
- package/models/report-builder.model.js.map +1 -0
- package/models/select-data-label.model.d.ts +9 -0
- package/models/select-data-label.model.js +4 -0
- package/models/select-data-label.model.js.map +1 -0
- package/models/server-response.model.d.ts +5 -0
- package/models/server-response.model.js +4 -0
- package/models/server-response.model.js.map +1 -0
- package/models/subscription.model.d.ts +23 -0
- package/models/subscription.model.js +4 -0
- package/models/subscription.model.js.map +1 -0
- package/models/support-ticket.model.d.ts +72 -0
- package/models/support-ticket.model.js +4 -0
- package/models/support-ticket.model.js.map +1 -0
- package/models/user-group.model.d.ts +19 -0
- package/models/user-group.model.js +4 -0
- package/models/user-group.model.js.map +1 -0
- package/{src/models/user-guide.model.ts → models/user-guide.model.d.ts} +4 -5
- package/models/user-guide.model.js +4 -0
- package/models/user-guide.model.js.map +1 -0
- package/models/user.model.d.ts +70 -0
- package/models/user.model.js +4 -0
- package/models/user.model.js.map +1 -0
- package/package.json +1 -1
- package/{src/public_api.ts → public_api.d.ts} +1 -1
- package/public_api.js +75 -0
- package/public_api.js.map +1 -0
- package/publications/app-status.d.ts +2 -0
- package/publications/app-status.js +17 -0
- package/publications/app-status.js.map +1 -0
- package/publications/cron-jobs.d.ts +2 -0
- package/publications/cron-jobs.js +33 -0
- package/publications/cron-jobs.js.map +1 -0
- package/publications/files.d.ts +2 -0
- package/publications/files.js +37 -0
- package/publications/files.js.map +1 -0
- package/publications/flags.d.ts +2 -0
- package/publications/flags.js +23 -0
- package/publications/flags.js.map +1 -0
- package/publications/logs.d.ts +2 -0
- package/publications/logs.js +165 -0
- package/publications/logs.js.map +1 -0
- package/publications/method-responses.d.ts +2 -0
- package/publications/method-responses.js +17 -0
- package/publications/method-responses.js.map +1 -0
- package/publications/notifications.d.ts +2 -0
- package/publications/notifications.js +17 -0
- package/publications/notifications.js.map +1 -0
- package/publications/report-builder-dashboard-builders.d.ts +2 -0
- package/publications/report-builder-dashboard-builders.js +43 -0
- package/publications/report-builder-dashboard-builders.js.map +1 -0
- package/publications/report-builder-libraries.d.ts +2 -0
- package/publications/report-builder-libraries.js +90 -0
- package/publications/report-builder-libraries.js.map +1 -0
- package/publications/report-builder-reports.d.ts +2 -0
- package/publications/report-builder-reports.js +51 -0
- package/publications/report-builder-reports.js.map +1 -0
- package/publications/super-admin.d.ts +2 -0
- package/publications/super-admin.js +17 -0
- package/publications/super-admin.js.map +1 -0
- package/publications/user-groups.d.ts +1 -0
- package/publications/user-groups.js +17 -0
- package/publications/user-groups.js.map +1 -0
- package/publications/user-guides.d.ts +1 -0
- package/publications/user-guides.js +17 -0
- package/publications/user-guides.js.map +1 -0
- package/server-app.d.ts +52 -0
- package/server-app.js +739 -0
- package/server-app.js.map +1 -0
- package/util/common.d.ts +24 -0
- package/util/common.js +511 -0
- package/util/common.js.map +1 -0
- package/util/schema-report-builder.d.ts +6 -0
- package/util/schema-report-builder.js +453 -0
- package/util/schema-report-builder.js.map +1 -0
- package/.nodemon.json +0 -5
- package/.vscode/settings.json +0 -3
- package/README.md +0 -22
- package/compileDTS.pl +0 -64
- package/gulpfile.js +0 -127
- package/mongodbensurers.js +0 -2
- package/mongostop.js +0 -3
- package/settings.development.json +0 -13
- package/src/client-server-app.ts +0 -7
- package/src/collections/app-status.collection.ts +0 -51
- package/src/collections/counter.collection.ts +0 -54
- package/src/collections/cron-job-history.collection.ts +0 -82
- package/src/collections/cron-job.collection.ts +0 -85
- package/src/collections/email-history.collection.ts +0 -66
- package/src/collections/email-verified.collection.ts +0 -61
- package/src/collections/file.collection.ts +0 -73
- package/src/collections/flag.collection.ts +0 -56
- package/src/collections/log-method-latency.collection.ts +0 -64
- package/src/collections/log-subscription.collection.ts +0 -68
- package/src/collections/log-ts.collection.ts +0 -78
- package/src/collections/log.collection.ts +0 -77
- package/src/collections/logged-in-users.collection.ts +0 -65
- package/src/collections/method-response.collection.ts +0 -66
- package/src/collections/monitor-cpu.collection.ts +0 -63
- package/src/collections/monitor-memory.collection.ts +0 -75
- package/src/collections/monitor-mongo.collection.ts +0 -69
- package/src/collections/notification.collection.ts +0 -51
- package/src/collections/report-builder-dashboard-builder.collection.ts +0 -109
- package/src/collections/report-builder-library.collection.ts +0 -89
- package/src/collections/report-builder-report.collection.ts +0 -149
- package/src/collections/user-group.collection.ts +0 -90
- package/src/collections/user-guide.collection.ts +0 -57
- package/src/collections/user.collection.ts +0 -259
- package/src/cron/cron.ts +0 -188
- package/src/fixtures/cron-jobs.ts +0 -25
- package/src/fixtures/init.ts +0 -10
- package/src/http/auth.ts +0 -732
- package/src/http/health.ts +0 -7
- package/src/http/home.ts +0 -71
- package/src/index.ts +0 -71
- package/src/managers/cron.manager.ts +0 -208
- package/src/managers/method.manager.ts +0 -607
- package/src/managers/mongo.manager.ts +0 -2282
- package/src/managers/monitor.manager.ts +0 -323
- package/src/managers/subscription.manager.ts +0 -1196
- package/src/methods/accounts.ts +0 -202
- package/src/methods/aws.ts +0 -507
- package/src/methods/collections.ts +0 -512
- package/src/methods/counters.ts +0 -75
- package/src/methods/cron-jobs.ts +0 -1454
- package/src/methods/flags.ts +0 -7
- package/src/methods/logs.ts +0 -327
- package/src/methods/monitor.ts +0 -548
- package/src/methods/pdf.ts +0 -615
- package/src/methods/report-builder.ts +0 -876
- package/src/methods/support.ts +0 -146
- package/src/models/collection-document.model.ts +0 -22
- package/src/models/cron-job-history.model.ts +0 -13
- package/src/models/cron-job.model.ts +0 -14
- package/src/models/dialog.model.ts +0 -25
- package/src/models/method.model.ts +0 -11
- package/src/models/monitor-memory.model.ts +0 -17
- package/src/models/monitor-mongo.model.ts +0 -15
- package/src/models/pagination.model.ts +0 -30
- package/src/models/permission.model.ts +0 -14
- package/src/models/report-builder-dashboard-builder.model.ts +0 -29
- package/src/models/report-builder-library.model.ts +0 -20
- package/src/models/report-builder-report.model.ts +0 -110
- package/src/models/report-builder.model.ts +0 -68
- package/src/models/select-data-label.model.ts +0 -9
- package/src/models/server-response.model.ts +0 -5
- package/src/models/subscription.model.ts +0 -64
- package/src/models/support-ticket.model.ts +0 -81
- package/src/models/user-group.model.ts +0 -23
- package/src/models/user.model.ts +0 -79
- package/src/publications/app-status.ts +0 -13
- package/src/publications/cron-jobs.ts +0 -30
- package/src/publications/files.ts +0 -34
- package/src/publications/flags.ts +0 -20
- package/src/publications/logs.ts +0 -164
- package/src/publications/method-responses.ts +0 -13
- package/src/publications/notifications.ts +0 -13
- package/src/publications/report-builder-dashboard-builders.ts +0 -39
- package/src/publications/report-builder-libraries.ts +0 -41
- package/src/publications/report-builder-reports.ts +0 -48
- package/src/publications/super-admin.ts +0 -13
- package/src/publications/user-groups.ts +0 -12
- package/src/publications/user-guides.ts +0 -12
- package/src/server-app.ts +0 -769
- package/src/util/common.ts +0 -519
- package/src/util/schema-report-builder.ts +0 -413
- package/tsconfig.json +0 -30
- package/tslint.json +0 -143
- /package/{src/private → private}/email-templates/enrollment.html +0 -0
- /package/{src/private → private}/email-templates/forgot-password.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-modified.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket.html +0 -0
- /package/{src/private → private}/images/ResolveIO.png +0 -0
|
@@ -1,607 +0,0 @@
|
|
|
1
|
-
import { ServerResponseModel } from '../models/server-response.model';
|
|
2
|
-
import { loadCollectionMethods } from '../methods/collections';
|
|
3
|
-
import { MethodModel } from '../models/method.model';
|
|
4
|
-
import { loadLogMethods } from '../methods/logs';
|
|
5
|
-
import { loadCounterMethods } from '../methods/counters';
|
|
6
|
-
import { loadPDFMethods } from '../methods/pdf';
|
|
7
|
-
import { loadAWSMethods } from '../methods/aws';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import * as fs from 'fs';
|
|
10
|
-
import * as nodemailer from 'nodemailer';
|
|
11
|
-
import * as sesTransport from 'nodemailer-ses-transport';
|
|
12
|
-
import { loadAccountMethods } from '../methods/accounts';
|
|
13
|
-
import { loadServerInit } from '../fixtures/init';
|
|
14
|
-
import { loadServerCronJobs } from '../fixtures/cron-jobs';
|
|
15
|
-
import { loadCronJobMethods } from '../methods/cron-jobs';
|
|
16
|
-
import { loadFlagMethods } from '../methods/flags';
|
|
17
|
-
import { MethodResponses } from '../collections/method-response.collection';
|
|
18
|
-
import { getBinarySize } from '../util/common';
|
|
19
|
-
import { Logs } from '../collections/log.collection';
|
|
20
|
-
import ResolveIOMainServer from '../server-app';
|
|
21
|
-
import { LogMethodLatencies } from '../collections/log-method-latency.collection';
|
|
22
|
-
import * as moment from 'moment';
|
|
23
|
-
import { loadReportBuilderMethods } from '../methods/report-builder';
|
|
24
|
-
import { loadSupportMethods } from '../methods/support';
|
|
25
|
-
import { loadMonitorMethods } from '../methods/monitor';
|
|
26
|
-
import { EmailHistories } from '../collections/email-history.collection';
|
|
27
|
-
import { objectIdHexString } from './mongo.manager';
|
|
28
|
-
import { MonitorManagerFunction } from './monitor.manager';
|
|
29
|
-
import { S3 } from '@aws-sdk/client-s3';
|
|
30
|
-
|
|
31
|
-
export class AWS {
|
|
32
|
-
private _serverConfig = null;
|
|
33
|
-
private _s3: S3 = null;
|
|
34
|
-
private _s3USEast1: S3 = null;
|
|
35
|
-
|
|
36
|
-
constructor(serverConfig) {
|
|
37
|
-
this._serverConfig = serverConfig;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public s3() : S3 {
|
|
41
|
-
if (this._s3) {
|
|
42
|
-
return this._s3;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this._s3 = new S3({
|
|
46
|
-
credentials: {
|
|
47
|
-
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
48
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
49
|
-
},
|
|
50
|
-
region: process.env.AWS_REGION,
|
|
51
|
-
apiVersion: '2006-03-01'
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return this._s3;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public s3USEast1() : S3 {
|
|
58
|
-
if (process.env.AWS_REGION === 'us-east-1') {
|
|
59
|
-
return this.s3();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (this._s3USEast1) {
|
|
63
|
-
return this._s3USEast1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this._s3USEast1 = new S3({
|
|
67
|
-
credentials: {
|
|
68
|
-
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
69
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
70
|
-
},
|
|
71
|
-
region: 'us-east-1',
|
|
72
|
-
apiVersion: '2006-03-01'
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return this._s3USEast1;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class MethodManager {
|
|
81
|
-
private _mainServer: ResolveIOMainServer;
|
|
82
|
-
public _methods: MethodModel = {};
|
|
83
|
-
private _mailer: nodemailer.Transporter;
|
|
84
|
-
private _aws: AWS;
|
|
85
|
-
private serverConfig;
|
|
86
|
-
private clientDir;
|
|
87
|
-
private _sendQueue = [];
|
|
88
|
-
private _runningQueue = false;
|
|
89
|
-
private _monitorManagerFunction: MonitorManagerFunction;
|
|
90
|
-
|
|
91
|
-
private _debugCallMethodInternalHits = 0;
|
|
92
|
-
private _debugCallMethodHits = 0;
|
|
93
|
-
private _debugCallMethodCronJobHits = 0;
|
|
94
|
-
private _debugSendQueueHits = 0;
|
|
95
|
-
|
|
96
|
-
constructor(mainServer, serverConfig, clientDir, monitorManagerFunction: MonitorManagerFunction) {
|
|
97
|
-
this._mainServer = mainServer;
|
|
98
|
-
this.serverConfig = serverConfig;
|
|
99
|
-
this.clientDir = clientDir;
|
|
100
|
-
this._monitorManagerFunction = monitorManagerFunction;
|
|
101
|
-
|
|
102
|
-
// Fixtures
|
|
103
|
-
loadServerInit();
|
|
104
|
-
loadServerCronJobs();
|
|
105
|
-
|
|
106
|
-
// Methods
|
|
107
|
-
loadAccountMethods(this);
|
|
108
|
-
loadAWSMethods(this);
|
|
109
|
-
loadCollectionMethods(this);
|
|
110
|
-
loadCounterMethods(this);
|
|
111
|
-
loadLogMethods(this);
|
|
112
|
-
loadPDFMethods(this);
|
|
113
|
-
loadCronJobMethods(this);
|
|
114
|
-
loadFlagMethods(this);
|
|
115
|
-
loadReportBuilderMethods(this);
|
|
116
|
-
loadSupportMethods(this);
|
|
117
|
-
loadMonitorMethods(this);
|
|
118
|
-
|
|
119
|
-
this._aws = new AWS(serverConfig);
|
|
120
|
-
|
|
121
|
-
if (mainServer.sesMail) {
|
|
122
|
-
this._mailer = nodemailer.createTransport(sesTransport({
|
|
123
|
-
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
124
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
125
|
-
region: process.env.AWS_SES_REGION
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this._mailer = nodemailer.createTransport({
|
|
130
|
-
host: this.serverConfig['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server
|
|
131
|
-
port: this.serverConfig['MAIL_PORT'], //587, // secure SMTP
|
|
132
|
-
secure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely
|
|
133
|
-
auth: {
|
|
134
|
-
user: this.serverConfig['MAIL_USERNAME'],
|
|
135
|
-
pass: this.serverConfig['MAIL_PASSWORD']
|
|
136
|
-
},
|
|
137
|
-
tls: {
|
|
138
|
-
ciphers: 'SSLv3'
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
setInterval(() => {
|
|
144
|
-
if (this._mainServer.getSubscriptionManager().getEnableDebug()) {
|
|
145
|
-
console.log(new Date(), 'Method Manager', 'Send Queue Length', this._sendQueue.length);
|
|
146
|
-
console.log(new Date(), 'Method Manager', 'Send Queue Hits', this._debugSendQueueHits);
|
|
147
|
-
console.log(new Date(), 'Method Manager', 'Call Method Internal Hits', this._debugCallMethodInternalHits);
|
|
148
|
-
console.log(new Date(), 'Method Manager', 'Call Method Hits', this._debugCallMethodHits);
|
|
149
|
-
console.log(new Date(), 'Method Manager', 'Call Method Cron Hits', this._debugCallMethodCronJobHits);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
this._debugCallMethodInternalHits = 0;
|
|
153
|
-
this._debugCallMethodHits = 0;
|
|
154
|
-
this._debugCallMethodCronJobHits = 0;
|
|
155
|
-
this._debugSendQueueHits = 0;
|
|
156
|
-
this._debugSendQueueHits = 0;
|
|
157
|
-
}, 60000);
|
|
158
|
-
|
|
159
|
-
setInterval(() => {
|
|
160
|
-
if (!this._runningQueue) {
|
|
161
|
-
if (this._sendQueue.length) {
|
|
162
|
-
this._runningQueue = true;
|
|
163
|
-
|
|
164
|
-
for (let i = this._sendQueue.length - 1; i >= 0; i--) {
|
|
165
|
-
this._debugSendQueueHits += 1;
|
|
166
|
-
|
|
167
|
-
let ws = this._mainServer.getWS(this._sendQueue[i].id_ws);
|
|
168
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
169
|
-
if (ws.bufferedAmount < 20480) {
|
|
170
|
-
let sendItem = this._sendQueue.pop();
|
|
171
|
-
ws.send(JSON.stringify(sendItem.data), (error) => {
|
|
172
|
-
if (error) {
|
|
173
|
-
console.log('Error on WS: ', error);
|
|
174
|
-
this._mainServer.unsubscribeWS(ws);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
if (sendItem.method !== 'reportBuilderGetResults' && sendItem.method !== 'reportBuilderGetDistinctValue' && sendItem.method !== 'reportBuilderBuildTree' && sendItem.method !== 'generatePDF' && sendItem.method !== 'getWOOfflineData' && sendItem.method !== 'countQuery' && sendItem.method !== 'countWithQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'uploadFileAndSave' && sendItem.method !== 'getDrivers' && sendItem.method !== 'processAirdropDistribution') {
|
|
179
|
-
Logs.insertOne({
|
|
180
|
-
_id: objectIdHexString(),
|
|
181
|
-
type: 'client-response',
|
|
182
|
-
collection: '',
|
|
183
|
-
id_document: '',
|
|
184
|
-
payload: getBinarySize(JSON.stringify([sendItem.methodData, sendItem.data])) < 200000 ? JSON.stringify([sendItem.methodData, sendItem.data], null, 2) : 'Too Big',
|
|
185
|
-
method: sendItem.method,
|
|
186
|
-
id_user: ws['id_user'] || '',
|
|
187
|
-
user: ws['user'] || '',
|
|
188
|
-
messageId: sendItem.data.messageId,
|
|
189
|
-
route: ''
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
MethodResponses.create({
|
|
194
|
-
_id: objectIdHexString(),
|
|
195
|
-
__v: 0,
|
|
196
|
-
id_user: ws['id_user'] || '',
|
|
197
|
-
message_id: sendItem.data.messageId,
|
|
198
|
-
response: getBinarySize(JSON.stringify(sendItem.data)) < 200000 ? sendItem.data : {error: 'Too Big'},
|
|
199
|
-
method: sendItem.method,
|
|
200
|
-
date: sendItem.date
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
this._sendQueue.splice(i, 1);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this._runningQueue = false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}, 25);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
public getMainServer() {
|
|
216
|
-
return this._mainServer;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Add methods to private methods object
|
|
220
|
-
public methods(method: MethodModel) {
|
|
221
|
-
this._methods = Object.assign(this._methods, method);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
public callMethodCron(method: string, ...methodData: any[]) {
|
|
225
|
-
this._debugCallMethodCronJobHits += 1;
|
|
226
|
-
|
|
227
|
-
if (!this._methods[method]) {
|
|
228
|
-
console.log('No Method: ' + method);
|
|
229
|
-
|
|
230
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
231
|
-
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
|
|
236
|
-
if (!this._methods[method].check) {
|
|
237
|
-
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
238
|
-
|
|
239
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
240
|
-
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
else if (!this._methods[method].check._schema) {
|
|
244
|
-
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
245
|
-
|
|
246
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
247
|
-
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
let valObj = {};
|
|
252
|
-
let valKeys = Object.keys(this._methods[method].check._schema);
|
|
253
|
-
|
|
254
|
-
let rootKeys = valKeys.filter(a => !a.includes('.'));
|
|
255
|
-
|
|
256
|
-
for (let i = 0; i < methodData.length; i++) {
|
|
257
|
-
valObj[rootKeys[i]] = methodData[i];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
try {
|
|
261
|
-
this._methods[method].check.validate(valObj);
|
|
262
|
-
}
|
|
263
|
-
catch (errors) {
|
|
264
|
-
if (errors) {
|
|
265
|
-
console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
|
|
266
|
-
|
|
267
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
268
|
-
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
let monitor = this._monitorManagerFunction.startMonitorFunction('Cron Method', method, '', '', methodData);
|
|
276
|
-
let promise = this._methods[method].function.call(Object.assign({}, this, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData)
|
|
277
|
-
.then(res => {
|
|
278
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
279
|
-
return res;
|
|
280
|
-
}, methodErrs => {
|
|
281
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
282
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodCron)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
283
|
-
return methodErrs;
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
return promise;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Call/run method (Emit on Socket)
|
|
290
|
-
public callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]) {
|
|
291
|
-
this._debugCallMethodHits += 1;
|
|
292
|
-
|
|
293
|
-
if (!this._methods[method]) {
|
|
294
|
-
console.log('No Method: ' + method);
|
|
295
|
-
|
|
296
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
297
|
-
|
|
298
|
-
let serverRes: ServerResponseModel = {
|
|
299
|
-
messageId: messageId,
|
|
300
|
-
hasError: true,
|
|
301
|
-
data: 'Internal Error'
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
305
|
-
|
|
306
|
-
if (id_methodLatency) {
|
|
307
|
-
LogMethodLatencies.deleteOne({_id: id_methodLatency});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
|
|
314
|
-
if (!this._methods[method].check) {
|
|
315
|
-
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
316
|
-
|
|
317
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
318
|
-
|
|
319
|
-
let serverRes: ServerResponseModel = {
|
|
320
|
-
messageId: messageId,
|
|
321
|
-
hasError: true,
|
|
322
|
-
data: 'Internal Error'
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
326
|
-
|
|
327
|
-
if (id_methodLatency) {
|
|
328
|
-
LogMethodLatencies.deleteOne({_id: id_methodLatency});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
else if (!this._methods[method].check._schema) {
|
|
334
|
-
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
335
|
-
|
|
336
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
337
|
-
|
|
338
|
-
let serverRes: ServerResponseModel = {
|
|
339
|
-
messageId: messageId,
|
|
340
|
-
hasError: true,
|
|
341
|
-
data: 'Internal Error'
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
if (id_methodLatency) {
|
|
345
|
-
LogMethodLatencies.deleteOne({_id: id_methodLatency});
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
349
|
-
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
let valObj = {};
|
|
354
|
-
let valKeys = Object.keys(this._methods[method].check._schema);
|
|
355
|
-
|
|
356
|
-
let rootKeys = valKeys.filter(a => !a.includes('.'));
|
|
357
|
-
|
|
358
|
-
for (let i = 0; i < methodData.length; i++) {
|
|
359
|
-
valObj[rootKeys[i]] = methodData[i];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
try {
|
|
363
|
-
this._methods[method].check.validate(valObj);
|
|
364
|
-
}
|
|
365
|
-
catch (errors) {
|
|
366
|
-
if (errors) {
|
|
367
|
-
console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
|
|
368
|
-
|
|
369
|
-
if (method !== 'processAirdropDistribution') {
|
|
370
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let serverRes: ServerResponseModel = {
|
|
374
|
-
messageId: messageId,
|
|
375
|
-
hasError: true,
|
|
376
|
-
data: 'Internal Error'
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
380
|
-
|
|
381
|
-
if (id_methodLatency) {
|
|
382
|
-
LogMethodLatencies.deleteOne({_id: id_methodLatency});
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
let monitor = this._monitorManagerFunction.startMonitorFunction('Method', method, ws['user'] || '', ws['id_socket'] || '', methodData);
|
|
392
|
-
this._methods[method].function.call(Object.assign({}, this, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData)
|
|
393
|
-
.then(async (res) => {
|
|
394
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
395
|
-
|
|
396
|
-
let serverRes: ServerResponseModel = {
|
|
397
|
-
messageId: messageId,
|
|
398
|
-
hasError: false,
|
|
399
|
-
data: res
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
403
|
-
|
|
404
|
-
if (id_methodLatency) {
|
|
405
|
-
let latency = await LogMethodLatencies.findById(id_methodLatency);
|
|
406
|
-
|
|
407
|
-
if (latency) {
|
|
408
|
-
LogMethodLatencies.updateOne({_id: id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}});
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}, err => {
|
|
412
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
413
|
-
let serverRes: ServerResponseModel = {
|
|
414
|
-
messageId: messageId,
|
|
415
|
-
hasError: true,
|
|
416
|
-
data: err
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
420
|
-
|
|
421
|
-
if (id_methodLatency) {
|
|
422
|
-
LogMethodLatencies.deleteOne({_id: id_methodLatency});
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
if (method !== 'processAirdropDistribution') {
|
|
426
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethod)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(err, null, 2));
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// Call/run method internal (No Emit on Socket)
|
|
432
|
-
public callMethodInternal(method, ...methodData: any[]): Promise<any> {
|
|
433
|
-
this._debugCallMethodInternalHits += 1;
|
|
434
|
-
|
|
435
|
-
if (!this._methods[method]) {
|
|
436
|
-
console.log('No Method: ' + method);
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !this._methods[method].skipValidation) {
|
|
441
|
-
if (!this._methods[method].check) {
|
|
442
|
-
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
else if (!this._methods[method].check._schema) {
|
|
446
|
-
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
447
|
-
return null;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (method !== 'insertSubscriptionLog' && method !== 'getDataURIfromURL' && method !== 'processAirdropDistribution') {
|
|
452
|
-
Logs.insertOne({
|
|
453
|
-
_id: objectIdHexString(),
|
|
454
|
-
type: 'callMethodInternal',
|
|
455
|
-
collection: '',
|
|
456
|
-
id_document: '',
|
|
457
|
-
payload: getBinarySize(JSON.stringify([methodData])) < 200000 ? JSON.stringify([methodData], null, 2) : 'Too Big',
|
|
458
|
-
method: method,
|
|
459
|
-
id_user: this['id_user'] || '',
|
|
460
|
-
user: this['user'] || '',
|
|
461
|
-
messageId: 0,
|
|
462
|
-
route: ''
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
let functionMethodData = typeof(methodData[methodData.length - 1]) === 'function' ? methodData.slice(0, -1) : methodData;
|
|
467
|
-
|
|
468
|
-
let monitor = this._monitorManagerFunction.startMonitorFunction('Internal Method', method, this['user'] || '', '', functionMethodData);
|
|
469
|
-
let promise = this._methods[method].function.call(Object.assign({}, this, MethodManager.prototype), ...functionMethodData)
|
|
470
|
-
.then(res => {
|
|
471
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
472
|
-
return res;
|
|
473
|
-
}, methodErrs => {
|
|
474
|
-
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
475
|
-
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodInternal)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
476
|
-
return methodErrs;
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
if (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {
|
|
480
|
-
promise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return promise;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
private sendWS(ws: WebSocket, messageDate: Date, method: string, methodData: any[], data: ServerResponseModel) {
|
|
487
|
-
this._sendQueue.splice(0, 0, {
|
|
488
|
-
id_ws: ws['id_socket'],
|
|
489
|
-
method: method,
|
|
490
|
-
methodData: methodData,
|
|
491
|
-
data: data,
|
|
492
|
-
date: messageDate
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
public sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string, reply_to?: string) {
|
|
497
|
-
return new Promise(async (resolve, reject) => {
|
|
498
|
-
if ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\@resolveio\.com/))) {
|
|
499
|
-
sendTo = 'dev@resolveio.com';
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (sendTo) {
|
|
503
|
-
if (this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
|
|
504
|
-
this._mailer.sendMail({
|
|
505
|
-
replyTo: reply_to !== null && reply_to !== undefined ? reply_to : (this.serverConfig['MAIL_REPLY_TO'] || undefined), //orders@acefluids.com
|
|
506
|
-
from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
507
|
-
to: sendTo,
|
|
508
|
-
subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) ? '(DEV SERVER) - ' : '') + subject,
|
|
509
|
-
text: text,
|
|
510
|
-
html: html,
|
|
511
|
-
attachments: attachments
|
|
512
|
-
}, (err, info) => {
|
|
513
|
-
if (err) {
|
|
514
|
-
console.log(err);
|
|
515
|
-
|
|
516
|
-
EmailHistories.create({
|
|
517
|
-
_id: objectIdHexString(),
|
|
518
|
-
__v: 0,
|
|
519
|
-
date: new Date(),
|
|
520
|
-
id_user: this['id_user'] || '',
|
|
521
|
-
user: this['user'] || '',
|
|
522
|
-
email: sendTo,
|
|
523
|
-
success: false,
|
|
524
|
-
verified: false
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
EmailHistories.create({
|
|
529
|
-
_id: objectIdHexString(),
|
|
530
|
-
__v: 0,
|
|
531
|
-
date: new Date(),
|
|
532
|
-
id_user: this['id_user'] || '',
|
|
533
|
-
user: this['user'] || '',
|
|
534
|
-
email: sendTo,
|
|
535
|
-
success: true,
|
|
536
|
-
verified: false
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
console.log('Send email', sendTo, subject, text, html, attachments, send_from);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
resolve(true);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
public getAWS(): AWS {
|
|
551
|
-
return this._aws;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
public readFile(fileName) {
|
|
555
|
-
return new Promise((resolve, reject) => {
|
|
556
|
-
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
557
|
-
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => {
|
|
558
|
-
if (err) {
|
|
559
|
-
reject(err);
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
resolve(res);
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
else {
|
|
567
|
-
if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
|
|
568
|
-
fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => {
|
|
569
|
-
if (err) {
|
|
570
|
-
reject(err);
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
573
|
-
resolve(res);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
public readImage(fileName) {
|
|
582
|
-
return new Promise((resolve, reject) => {
|
|
583
|
-
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
584
|
-
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => {
|
|
585
|
-
if (err) {
|
|
586
|
-
reject(err);
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
resolve(res);
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
|
|
595
|
-
fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => {
|
|
596
|
-
if (err) {
|
|
597
|
-
reject(err);
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
resolve(res);
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
}
|