scheduler-node-models 1.2.91 → 1.2.93

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.
@@ -0,0 +1,3 @@
1
+ export * from './logging';
2
+ export * from './mariadb';
3
+ export * from './mongoconnect';
@@ -0,0 +1,19 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./logging"), exports);
18
+ __exportStar(require("./mariadb"), exports);
19
+ __exportStar(require("./mongoconnect"), exports);
@@ -0,0 +1,5 @@
1
+ import { Logger } from '../general';
2
+ export declare const logConnection: {
3
+ log?: Logger;
4
+ };
5
+ export declare function createLogs(application: string): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logConnection = void 0;
4
+ exports.createLogs = createLogs;
5
+ const general_1 = require("../general");
6
+ exports.logConnection = {};
7
+ async function createLogs(application) {
8
+ exports.logConnection.log = new general_1.Logger(`${process.env.LOG_DIR}/${application}/process_${(new Date().toDateString())}.log`);
9
+ }
@@ -0,0 +1,5 @@
1
+ import * as mariadb from 'mariadb';
2
+ export declare const mdbConnection: {
3
+ pool?: mariadb.Pool;
4
+ };
5
+ export declare function createPool(): Promise<void>;
@@ -0,0 +1,50 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.mdbConnection = void 0;
37
+ exports.createPool = createPool;
38
+ const mariadb = __importStar(require("mariadb"));
39
+ exports.mdbConnection = {};
40
+ async function createPool() {
41
+ exports.mdbConnection.pool = await mariadb.createPool({
42
+ host: process.env.MYSQL_SERVER,
43
+ port: (process.env.MYSQL_PORT) ? Number(process.env.MYSQL_PORT) : 3306,
44
+ user: process.env.MYSQL_USER,
45
+ password: process.env.MYSQL_PASSWORD,
46
+ database: 'scheduler',
47
+ connectionLimit: 5
48
+ });
49
+ console.log('Connected to mariadb');
50
+ }
@@ -0,0 +1,12 @@
1
+ import { Collection } from 'mongodb';
2
+ export declare const collections: {
3
+ users?: Collection;
4
+ employees?: Collection;
5
+ work?: Collection;
6
+ notifications?: Collection;
7
+ teams?: Collection;
8
+ help?: Collection;
9
+ missions?: Collection;
10
+ outages?: Collection;
11
+ };
12
+ export declare function connectToDB(): Promise<void>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collections = void 0;
4
+ exports.connectToDB = connectToDB;
5
+ const mongodb_1 = require("mongodb");
6
+ exports.collections = {};
7
+ async function connectToDB() {
8
+ const uri = `mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@`
9
+ + `${process.env.MONGO_SERVER}:${process.env.MONGO_PORT}?`
10
+ + `${process.env.MONGO_APPEND}`;
11
+ if (uri) {
12
+ try {
13
+ const client = new mongodb_1.MongoClient(uri);
14
+ await client.connect();
15
+ console.log('Connected to database');
16
+ const db = client.db('scheduler');
17
+ let users = client.db('authenticate').collection("users");
18
+ if (!users) {
19
+ users = await db.createCollection("users");
20
+ }
21
+ exports.collections.users = users;
22
+ let employees = db.collection("employees");
23
+ if (!employees) {
24
+ employees = await db.createCollection("employees");
25
+ }
26
+ exports.collections.employees = employees;
27
+ let work = db.collection('employeework');
28
+ if (!work) {
29
+ work = await db.createCollection("employeework");
30
+ }
31
+ exports.collections.work = work;
32
+ let notifications = db.collection("notifications");
33
+ if (!notifications) {
34
+ notifications = await db.createCollection("notifications");
35
+ }
36
+ exports.collections.notifications = notifications;
37
+ let teams = await db.collection('teams');
38
+ if (!teams) {
39
+ teams = await db.createCollection('teams');
40
+ }
41
+ exports.collections.teams = teams;
42
+ let help = await db.collection('help');
43
+ if (!help) {
44
+ help = await db.createCollection('help');
45
+ }
46
+ exports.collections.help = help;
47
+ // set up the metrics database and collection tables
48
+ const metricsDB = client.db('metrics2');
49
+ let missions = metricsDB.collection('missions');
50
+ if (!missions) {
51
+ missions = await db.createCollection('missions');
52
+ }
53
+ exports.collections.missions = missions;
54
+ let outages = metricsDB.collection('outages');
55
+ if (!outages) {
56
+ outages = await metricsDB.createCollection('outages');
57
+ }
58
+ exports.collections.outages = outages;
59
+ console.log('Successfully connected to collections');
60
+ }
61
+ catch (error) {
62
+ console.log(error);
63
+ }
64
+ }
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler-node-models",
3
- "version": "1.2.91",
3
+ "version": "1.2.93",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [