@churchapps/apihelper 0.0.1
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/auth/AuthenticatedUser.d.ts +17 -0
- package/dist/auth/AuthenticatedUser.d.ts.map +1 -0
- package/dist/auth/AuthenticatedUser.js +31 -0
- package/dist/auth/AuthenticatedUser.js.map +1 -0
- package/dist/auth/CustomAuthProvider.d.ts +7 -0
- package/dist/auth/CustomAuthProvider.d.ts.map +1 -0
- package/dist/auth/CustomAuthProvider.js +46 -0
- package/dist/auth/CustomAuthProvider.js.map +1 -0
- package/dist/auth/Principal.d.ts +9 -0
- package/dist/auth/Principal.d.ts.map +1 -0
- package/dist/auth/Principal.js +19 -0
- package/dist/auth/Principal.js.map +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/controllers/CustomBaseController.d.ts +15 -0
- package/dist/controllers/CustomBaseController.d.ts.map +1 -0
- package/dist/controllers/CustomBaseController.js +83 -0
- package/dist/controllers/CustomBaseController.js.map +1 -0
- package/dist/controllers/ErrorController.d.ts +7 -0
- package/dist/controllers/ErrorController.d.ts.map +1 -0
- package/dist/controllers/ErrorController.js +63 -0
- package/dist/controllers/ErrorController.js.map +1 -0
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +8 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/helpers/AwsHelper.d.ts +13 -0
- package/dist/helpers/AwsHelper.d.ts.map +1 -0
- package/dist/helpers/AwsHelper.js +131 -0
- package/dist/helpers/AwsHelper.js.map +1 -0
- package/dist/helpers/BasePermissions.d.ts +31 -0
- package/dist/helpers/BasePermissions.d.ts.map +1 -0
- package/dist/helpers/BasePermissions.js +20 -0
- package/dist/helpers/BasePermissions.js.map +1 -0
- package/dist/helpers/DB.d.ts +8 -0
- package/dist/helpers/DB.d.ts.map +1 -0
- package/dist/helpers/DB.js +72 -0
- package/dist/helpers/DB.js.map +1 -0
- package/dist/helpers/DBCreator.d.ts +6 -0
- package/dist/helpers/DBCreator.d.ts.map +1 -0
- package/dist/helpers/DBCreator.js +56 -0
- package/dist/helpers/DBCreator.js.map +1 -0
- package/dist/helpers/EmailHelper.d.ts +7 -0
- package/dist/helpers/EmailHelper.d.ts.map +1 -0
- package/dist/helpers/EmailHelper.js +81 -0
- package/dist/helpers/EmailHelper.js.map +1 -0
- package/dist/helpers/EncryptionHelper.d.ts +6 -0
- package/dist/helpers/EncryptionHelper.d.ts.map +1 -0
- package/dist/helpers/EncryptionHelper.js +31 -0
- package/dist/helpers/EncryptionHelper.js.map +1 -0
- package/dist/helpers/EnvironmentBase.d.ts +17 -0
- package/dist/helpers/EnvironmentBase.d.ts.map +1 -0
- package/dist/helpers/EnvironmentBase.js +22 -0
- package/dist/helpers/EnvironmentBase.js.map +1 -0
- package/dist/helpers/FileStorageHelper.d.ts +15 -0
- package/dist/helpers/FileStorageHelper.d.ts.map +1 -0
- package/dist/helpers/FileStorageHelper.js +99 -0
- package/dist/helpers/FileStorageHelper.js.map +1 -0
- package/dist/helpers/Interfaces.d.ts +12 -0
- package/dist/helpers/Interfaces.d.ts.map +1 -0
- package/dist/helpers/Interfaces.js +3 -0
- package/dist/helpers/Interfaces.js.map +1 -0
- package/dist/helpers/LoggingHelper.d.ts +15 -0
- package/dist/helpers/LoggingHelper.d.ts.map +1 -0
- package/dist/helpers/LoggingHelper.js +83 -0
- package/dist/helpers/LoggingHelper.js.map +1 -0
- package/dist/helpers/MySqlHelper.d.ts +4 -0
- package/dist/helpers/MySqlHelper.d.ts.map +1 -0
- package/dist/helpers/MySqlHelper.js +10 -0
- package/dist/helpers/MySqlHelper.js.map +1 -0
- package/dist/helpers/OmitEmpty.d.ts +6 -0
- package/dist/helpers/OmitEmpty.d.ts.map +1 -0
- package/dist/helpers/OmitEmpty.js +94 -0
- package/dist/helpers/OmitEmpty.js.map +1 -0
- package/dist/helpers/Pool.d.ts +7 -0
- package/dist/helpers/Pool.d.ts.map +1 -0
- package/dist/helpers/Pool.js +55 -0
- package/dist/helpers/Pool.js.map +1 -0
- package/dist/helpers/index.d.ts +15 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +31 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/models/ErrorLog.d.ts +7 -0
- package/dist/models/ErrorLog.d.ts.map +1 -0
- package/dist/models/ErrorLog.js +7 -0
- package/dist/models/ErrorLog.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -0
- package/dist/models/index.js.map +1 -0
- package/dist/tools/DBCreator.d.ts +1 -0
- package/dist/tools/DBCreator.d.ts.map +1 -0
- package/dist/tools/DBCreator.js +1 -0
- package/dist/tools/DBCreator.js.map +1 -0
- package/package.json +60 -0
- package/src/auth/AuthenticatedUser.ts +40 -0
- package/src/auth/CustomAuthProvider.ts +23 -0
- package/src/auth/Principal.ts +22 -0
- package/src/auth/index.ts +3 -0
- package/src/controllers/CustomBaseController.ts +74 -0
- package/src/controllers/ErrorController.ts +33 -0
- package/src/controllers/index.ts +2 -0
- package/src/helpers/AwsHelper.ts +108 -0
- package/src/helpers/BasePermissions.ts +15 -0
- package/src/helpers/DB.ts +41 -0
- package/src/helpers/DBCreator.ts +39 -0
- package/src/helpers/EmailHelper.ts +66 -0
- package/src/helpers/EncryptionHelper.ts +25 -0
- package/src/helpers/EnvironmentBase.ts +35 -0
- package/src/helpers/FileStorageHelper.ts +71 -0
- package/src/helpers/Interfaces.ts +2 -0
- package/src/helpers/LoggingHelper.ts +75 -0
- package/src/helpers/MySqlHelper.ts +5 -0
- package/src/helpers/OmitEmpty.ts +97 -0
- package/src/helpers/Pool.ts +55 -0
- package/src/helpers/index.ts +14 -0
- package/src/index.ts +3 -0
- package/src/models/ErrorLog.ts +7 -0
- package/src/models/index.ts +1 -0
- package/src/tools/DBCreator.ts +0 -0
- package/src/tools/templates/ChurchEmailTemplate.html +383 -0
- package/src/tools/templates/EmailTemplate.html +426 -0
- package/tsconfig.json +39 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasePermissions = void 0;
|
|
4
|
+
class BasePermissions {
|
|
5
|
+
}
|
|
6
|
+
exports.BasePermissions = BasePermissions;
|
|
7
|
+
BasePermissions.forms = {
|
|
8
|
+
admin: { contentType: "Forms", action: "Admin" },
|
|
9
|
+
edit: { contentType: "Forms", action: "Edit" }
|
|
10
|
+
};
|
|
11
|
+
BasePermissions.links = {
|
|
12
|
+
edit: { contentType: "Links", action: "Edit" }
|
|
13
|
+
};
|
|
14
|
+
BasePermissions.pages = {
|
|
15
|
+
edit: { contentType: "Pages", action: "Edit" }
|
|
16
|
+
};
|
|
17
|
+
BasePermissions.settings = {
|
|
18
|
+
edit: { contentType: "Settings", action: "Edit" }
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=BasePermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePermissions.js","sourceRoot":"","sources":["../../src/helpers/BasePermissions.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;;AAA5B,0CAcC;AAbQ,qBAAK,GAAG;IACb,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IAChD,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;CAC/C,CAAC;AACK,qBAAK,GAAG;IACb,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;CAC/C,CAAC;AACK,qBAAK,GAAG;IACb,IAAI,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;CAC/C,CAAC;AACK,wBAAQ,GAAG;IAChB,IAAI,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;CAClD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PoolConnection, queryCallback } from "mysql";
|
|
2
|
+
export declare class DB {
|
|
3
|
+
static getConnection(): Promise<PoolConnection>;
|
|
4
|
+
static getQuery(connection: PoolConnection, sql: string, params: any[]): Promise<queryCallback>;
|
|
5
|
+
static query(sql: string, params: any[]): Promise<any>;
|
|
6
|
+
static queryOne(sql: string, params: any[]): Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=DB.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DB.d.ts","sourceRoot":"","sources":["../../src/helpers/DB.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAc,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlE,qBAAa,EAAE;WAGE,aAAa;WASb,QAAQ,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;WAWxD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;WAShC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;CAI1D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DB = void 0;
|
|
13
|
+
const Pool_1 = require("./Pool");
|
|
14
|
+
const LoggingHelper_1 = require("./LoggingHelper");
|
|
15
|
+
class DB {
|
|
16
|
+
// wraps in promise
|
|
17
|
+
static getConnection() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const promise = new Promise((resolve, reject) => {
|
|
20
|
+
Pool_1.Pool.current.getConnection((ex, conn) => { if (ex)
|
|
21
|
+
reject(ex);
|
|
22
|
+
else
|
|
23
|
+
resolve(conn); });
|
|
24
|
+
});
|
|
25
|
+
;
|
|
26
|
+
const connection = yield promise;
|
|
27
|
+
return connection;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// wraps in promise
|
|
31
|
+
static getQuery(connection, sql, params) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const promise = new Promise((resolve, reject) => {
|
|
34
|
+
connection.query(sql, params, (ex, rows) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (ex) {
|
|
36
|
+
LoggingHelper_1.LoggingHelper.getCurrent().error(ex);
|
|
37
|
+
reject(ex);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
resolve(rows);
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
const query = yield promise;
|
|
45
|
+
return query;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
static query(sql, params) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
let result = null;
|
|
51
|
+
const connection = yield this.getConnection();
|
|
52
|
+
try {
|
|
53
|
+
result = yield this.getQuery(connection, sql, params);
|
|
54
|
+
}
|
|
55
|
+
catch (ex) {
|
|
56
|
+
LoggingHelper_1.LoggingHelper.getCurrent().error(ex);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
connection.release();
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
static queryOne(sql, params) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const result = yield this.query(sql, params);
|
|
67
|
+
return result.length > 0 ? result[0] : null;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.DB = DB;
|
|
72
|
+
//# sourceMappingURL=DB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DB.js","sourceRoot":"","sources":["../../src/helpers/DB.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8B;AAE9B,mDAAgD;AAEhD,MAAa,EAAE;IAEX,mBAAmB;IACnB,MAAM,CAAO,aAAa;;YACtB,MAAM,OAAO,GAA4B,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrE,WAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAc,EAAE,IAAoB,EAAE,EAAE,GAAG,IAAI,EAAE;oBAAE,MAAM,CAAC,EAAE,CAAC,CAAC;;oBAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtH,CAAC,CAAC,CAAC;YAAA,CAAC;YACJ,MAAM,UAAU,GAAmB,MAAM,OAAO,CAAC;YACjD,OAAO,UAAU,CAAC;QACtB,CAAC;KAAA;IAED,mBAAmB;IACnB,MAAM,CAAO,QAAQ,CAAC,UAA0B,EAAE,GAAW,EAAE,MAAa;;YACxE,MAAM,OAAO,GAA2B,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACpE,UAAU,CAAC,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/DBCreator.ts"],"names":[],"mappings":"AAIA,qBAAa,SAAS;IAEpB,OAAO,CAAC,MAAM,CAAC,MAAM,CAIpB;WAEmB,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE;WAc7B,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO;CAYpF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.DBCreator = void 0;
|
|
16
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const DB_1 = require("./DB");
|
|
19
|
+
class DBCreator {
|
|
20
|
+
static init(selectedTables) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
dotenv_1.default.config();
|
|
23
|
+
const todo = [];
|
|
24
|
+
selectedTables.forEach((st) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.tables.forEach((t) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (t.title === st)
|
|
27
|
+
todo.push(t);
|
|
28
|
+
}));
|
|
29
|
+
}));
|
|
30
|
+
for (const td of todo)
|
|
31
|
+
yield this.runScript(td.title, "./src/apiBase/tools/dbScripts/" + td.file, false);
|
|
32
|
+
return;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
static runScript(title, file, customDelimeter) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
console.log("Creating '" + title + "'");
|
|
38
|
+
const sql = yield fs_extra_1.default.readFile(file, { encoding: "UTF-8" });
|
|
39
|
+
let del = /;(?=END)\s*$|;(?!\nEND)\s*$/gm;
|
|
40
|
+
if (customDelimeter) {
|
|
41
|
+
del = /\$\$$/gm;
|
|
42
|
+
}
|
|
43
|
+
const statements = sql.split(del);
|
|
44
|
+
for (const statement of statements)
|
|
45
|
+
if (statement.length > 3)
|
|
46
|
+
yield DB_1.DB.query(statement, []);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.DBCreator = DBCreator;
|
|
51
|
+
DBCreator.tables = [
|
|
52
|
+
{ title: "Links", file: "links.mysql" },
|
|
53
|
+
{ title: "Pages", file: "pages.mysql" },
|
|
54
|
+
{ title: "Settings", file: "settings.mysql" },
|
|
55
|
+
];
|
|
56
|
+
//# sourceMappingURL=DBCreator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DBCreator.js","sourceRoot":"","sources":["../../src/helpers/DBCreator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,wDAA0B;AAC1B,6BAA0B;AAE1B,MAAa,SAAS;IAQb,MAAM,CAAO,IAAI,CAAC,cAAwB;;YAC/C,gBAAM,CAAC,MAAM,EAAE,CAAC;YAEhB,MAAM,IAAI,GAAsC,EAAE,CAAC;YACnD,cAAc,CAAC,OAAO,CAAC,CAAM,EAAE,EAAC,EAAE;gBAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAM,CA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2
|
+
export declare class EmailHelper {
|
|
3
|
+
static sendTemplatedEmail(from: string, to: string, appName: string, appUrl: string, subject: string, contents: string, emailTemplate?: "EmailTemplate.html" | "ChurchEmailTemplate.html"): Promise<void>;
|
|
4
|
+
static readTemplate(templateFile?: string): string;
|
|
5
|
+
static sendEmail({ from, to, subject, body }: IEmailPayload): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=EmailHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/EmailHelper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,aAAa,EAAE,MAAM,GAAG,CAAA;AAIlD,qBAAa,WAAW;WAEF,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,GAAE,oBAAoB,GAAG,0BAAiD;WAW9M,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM;WAQlC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,aAAa;CAqCnE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.EmailHelper = void 0;
|
|
16
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
17
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
18
|
+
const nodemailer_direct_transport_1 = __importDefault(require("nodemailer-direct-transport"));
|
|
19
|
+
const _1 = require(".");
|
|
20
|
+
const fs_1 = __importDefault(require("fs"));
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
class EmailHelper {
|
|
23
|
+
static sendTemplatedEmail(from, to, appName, appUrl, subject, contents, emailTemplate = "EmailTemplate.html") {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (!appName)
|
|
26
|
+
appName = "Chums";
|
|
27
|
+
if (!appUrl)
|
|
28
|
+
appUrl = "https://chums.org";
|
|
29
|
+
const template = EmailHelper.readTemplate(emailTemplate);
|
|
30
|
+
const emailBody = template
|
|
31
|
+
.replace("{appLink}", "<a href=\"" + appUrl + "/\">" + appName + "</a>")
|
|
32
|
+
.replace("{contents}", contents);
|
|
33
|
+
yield EmailHelper.sendEmail({ from, to, subject, body: emailBody });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static readTemplate(templateFile) {
|
|
37
|
+
if (!templateFile)
|
|
38
|
+
templateFile = "EmailTemplate.html";
|
|
39
|
+
const filePath = path_1.default.join(__dirname, "../../templates/" + templateFile);
|
|
40
|
+
const buffer = fs_1.default.readFileSync(filePath);
|
|
41
|
+
const contents = buffer.toString();
|
|
42
|
+
return contents;
|
|
43
|
+
}
|
|
44
|
+
static sendEmail({ from, to, subject, body }) {
|
|
45
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
let transporter = nodemailer_1.default.createTransport((0, nodemailer_direct_transport_1.default)({
|
|
48
|
+
name: "churchapps.org"
|
|
49
|
+
}));
|
|
50
|
+
if (_1.EnvironmentBase.mailSystem === 'SES') {
|
|
51
|
+
aws_sdk_1.default.config.update({ region: 'us-east-2' });
|
|
52
|
+
const ses = new aws_sdk_1.default.SES({ apiVersion: '2010-12-01' });
|
|
53
|
+
transporter = nodemailer_1.default.createTransport({ SES: { ses, aws: aws_sdk_1.default } });
|
|
54
|
+
}
|
|
55
|
+
if (_1.EnvironmentBase.mailSystem === "SMTP") {
|
|
56
|
+
transporter = nodemailer_1.default.createTransport({
|
|
57
|
+
host: _1.EnvironmentBase.smtpHost,
|
|
58
|
+
secure: _1.EnvironmentBase.smtpSecure,
|
|
59
|
+
auth: {
|
|
60
|
+
user: _1.EnvironmentBase.smtpUser,
|
|
61
|
+
pass: _1.EnvironmentBase.smtpPass
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (_1.EnvironmentBase.mailSystem === "") {
|
|
66
|
+
console.log("****Email server not configured: ");
|
|
67
|
+
console.log(subject);
|
|
68
|
+
console.log(body);
|
|
69
|
+
}
|
|
70
|
+
else
|
|
71
|
+
yield transporter.sendMail({ from, to, subject, html: body });
|
|
72
|
+
resolve(null);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
reject(err);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.EmailHelper = EmailHelper;
|
|
81
|
+
//# sourceMappingURL=EmailHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailHelper.js","sourceRoot":"","sources":["../../src/helpers/EmailHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAyB;AACzB,4DAAmC;AACnC,8FAAyD;AACzD,wBAAkD;AAClD,4CAAoB;AACpB,gDAAwB;AAExB,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
1
|
+
{"version":3,"file":"EncryptionHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/EncryptionHelper.ts"],"names":[],"mappings":"AAGA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiB;IAEzC,MAAM,CAAC,OAAO,eAAgB,MAAM,YAKnC;IAED,MAAM,CAAC,OAAO,kBAAmB,MAAM,YAUtC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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.EncryptionHelper = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
class EncryptionHelper {
|
|
10
|
+
}
|
|
11
|
+
exports.EncryptionHelper = EncryptionHelper;
|
|
12
|
+
EncryptionHelper.algorithm = 'aes-256-ctr';
|
|
13
|
+
EncryptionHelper.encrypt = (plainValue) => {
|
|
14
|
+
const iv = crypto_1.default.randomBytes(16);
|
|
15
|
+
const cipher = crypto_1.default.createCipheriv(EncryptionHelper.algorithm, _1.EnvironmentBase.encryptionKey, iv);
|
|
16
|
+
const encrypted = Buffer.concat([cipher.update(plainValue), cipher.final()]);
|
|
17
|
+
return iv.toString('base64') + "|" + encrypted.toString('base64');
|
|
18
|
+
};
|
|
19
|
+
EncryptionHelper.decrypt = (encryptedPair) => {
|
|
20
|
+
const parts = encryptedPair.split("|");
|
|
21
|
+
if (parts.length !== 2)
|
|
22
|
+
return "";
|
|
23
|
+
else {
|
|
24
|
+
const iv = Buffer.from(parts[0], 'base64');
|
|
25
|
+
const content = Buffer.from(parts[1], 'base64');
|
|
26
|
+
const decipher = crypto_1.default.createDecipheriv(EncryptionHelper.algorithm, _1.EnvironmentBase.encryptionKey, iv);
|
|
27
|
+
const decrpyted = Buffer.concat([decipher.update(content), decipher.final()]);
|
|
28
|
+
return decrpyted.toString();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=EncryptionHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptionHelper.js","sourceRoot":"","sources":["../../src/helpers/EncryptionHelper.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,wBAAoC;AAEpC,MAAa,gBAAgB;;AAA7B,4CAqBC;AApBgB,0BAAS,GAAG,aAAa,CAAC;AAElC,wBAAO,GAAG,CAAC,UAAkB,EAAE,EAAE;IACtC,MAAM,EAAE,GAAG,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,gBAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,SAAS,EAAE,kBAAe,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACpG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7E,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpE,CAAC,CAAA;AAEM,wBAAO,GAAG,CAAC,aAAqB,EAAE,EAAE;IACzC,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;SAC7B;QACH,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,gBAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,SAAS,EAAE,kBAAe,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACxG,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC9E,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;KAC7B;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class EnvironmentBase {
|
|
2
|
+
static appEnv: string;
|
|
3
|
+
static appName: string;
|
|
4
|
+
static s3Bucket: string;
|
|
5
|
+
static connectionString: string;
|
|
6
|
+
static contentRoot: string;
|
|
7
|
+
static encryptionKey: string;
|
|
8
|
+
static fileStore: string;
|
|
9
|
+
static jwtSecret: string;
|
|
10
|
+
static mailSystem: string;
|
|
11
|
+
static smtpHost: string;
|
|
12
|
+
static smtpPass: string;
|
|
13
|
+
static smtpSecure: boolean;
|
|
14
|
+
static smtpUser: string;
|
|
15
|
+
static populateBase(jsonData: any): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EnvironmentBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentBase.d.ts","sourceRoot":"","sources":["../../src/helpers/EnvironmentBase.ts"],"names":[],"mappings":"AACA,qBAAa,eAAe;IAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAChC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;IAEzB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;IAGxB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG;CAgBlC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvironmentBase = void 0;
|
|
4
|
+
class EnvironmentBase {
|
|
5
|
+
static populateBase(jsonData) {
|
|
6
|
+
EnvironmentBase.appName = jsonData.appName;
|
|
7
|
+
EnvironmentBase.appEnv = jsonData.appEnv;
|
|
8
|
+
EnvironmentBase.connectionString = process.env.CONNECTION_STRING;
|
|
9
|
+
EnvironmentBase.contentRoot = jsonData.contentRoot;
|
|
10
|
+
EnvironmentBase.encryptionKey = process.env.ENCRYPTION_KEY;
|
|
11
|
+
EnvironmentBase.fileStore = jsonData.fileStore;
|
|
12
|
+
EnvironmentBase.jwtSecret = process.env.JWT_SECRET;
|
|
13
|
+
EnvironmentBase.mailSystem = jsonData.mailSystem;
|
|
14
|
+
EnvironmentBase.s3Bucket = jsonData.s3Bucket;
|
|
15
|
+
EnvironmentBase.smtpHost = process.env.SMTP_HOST;
|
|
16
|
+
EnvironmentBase.smtpPass = process.env.SMTP_PASS;
|
|
17
|
+
EnvironmentBase.smtpSecure = process.env.SMTP_SECURE === "true";
|
|
18
|
+
EnvironmentBase.smtpUser = process.env.SMTP_USER;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.EnvironmentBase = EnvironmentBase;
|
|
22
|
+
//# sourceMappingURL=EnvironmentBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnvironmentBase.js","sourceRoot":"","sources":["../../src/helpers/EnvironmentBase.ts"],"names":[],"mappings":";;;AACA,MAAa,eAAe;IAiB1B,MAAM,CAAC,YAAY,CAAC,QAAa;QAC/B,eAAe,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC3C,eAAe,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QACzC,eAAe,CAAC,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACjE,eAAe,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;QACnD,eAAe,CAAC,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC3D,eAAe,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC/C,eAAe,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QACnD,eAAe,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACjD,eAAe,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAC7C,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACjD,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACjD,eAAe,CAAC,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAChE,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IACnD,CAAC;CAEF;AAjCD,0CAiCC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare class FileStorageHelper {
|
|
3
|
+
private static rootPath;
|
|
4
|
+
static list: (filePath: string) => Promise<string[]>;
|
|
5
|
+
static move: (oldKey: string, newKey: string) => Promise<void>;
|
|
6
|
+
static store: (key: string, contentType: string, contents: Buffer) => Promise<void>;
|
|
7
|
+
static remove: (key: string) => Promise<void>;
|
|
8
|
+
static removeFolder: (key: string) => Promise<void>;
|
|
9
|
+
private static storeLocal;
|
|
10
|
+
private static moveLocal;
|
|
11
|
+
private static removeLocal;
|
|
12
|
+
private static removeLocalFolder;
|
|
13
|
+
private static listLocal;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=FileStorageHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/FileStorageHelper.ts"],"names":[],"mappings":";AAKA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmC;IAE1D,MAAM,CAAC,IAAI,aAAoB,MAAM,uBAOpC;IAED,MAAM,CAAC,IAAI,WAAkB,MAAM,UAAU,MAAM,mBAKlD;IAED,MAAM,CAAC,KAAK,QAAe,MAAM,eAAe,MAAM,YAAY,MAAM,mBAKvE;IAED,MAAM,CAAC,MAAM,QAAe,MAAM,mBAKjC;IAED,MAAM,CAAC,YAAY,QAAe,MAAM,mBAKvC;IAED,OAAO,CAAC,MAAM,CAAC,UAAU,CAKxB;IAED,OAAO,CAAC,MAAM,CAAC,SAAS,CAEvB;IAED,OAAO,CAAC,MAAM,CAAC,WAAW,CAEzB;IAED,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAE/B;IAED,OAAO,CAAC,MAAM,CAAC,SAAS,CAIvB;CAEF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.FileStorageHelper = void 0;
|
|
17
|
+
const AwsHelper_1 = require("./AwsHelper");
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const _1 = require(".");
|
|
21
|
+
class FileStorageHelper {
|
|
22
|
+
}
|
|
23
|
+
exports.FileStorageHelper = FileStorageHelper;
|
|
24
|
+
_a = FileStorageHelper;
|
|
25
|
+
FileStorageHelper.rootPath = path_1.default.resolve("./content") + "/";
|
|
26
|
+
FileStorageHelper.list = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
let result = [];
|
|
28
|
+
switch (_1.EnvironmentBase.fileStore) {
|
|
29
|
+
case "S3":
|
|
30
|
+
result = yield AwsHelper_1.AwsHelper.S3List(filePath);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
result = yield _a.listLocal(filePath);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
});
|
|
38
|
+
FileStorageHelper.move = (oldKey, newKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
switch (_1.EnvironmentBase.fileStore) {
|
|
40
|
+
case "S3":
|
|
41
|
+
yield AwsHelper_1.AwsHelper.S3Move(oldKey, newKey);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
yield _a.moveLocal(oldKey, newKey);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
FileStorageHelper.store = (key, contentType, contents) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
switch (_1.EnvironmentBase.fileStore) {
|
|
50
|
+
case "S3":
|
|
51
|
+
yield AwsHelper_1.AwsHelper.S3Upload(key, contentType, contents);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
yield _a.storeLocal(key, contents);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
FileStorageHelper.remove = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
switch (_1.EnvironmentBase.fileStore) {
|
|
60
|
+
case "S3":
|
|
61
|
+
yield AwsHelper_1.AwsHelper.S3Remove(key);
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
yield _a.removeLocal(key);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
FileStorageHelper.removeFolder = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
switch (_1.EnvironmentBase.fileStore) {
|
|
70
|
+
case "S3": break; // no need on s3
|
|
71
|
+
default:
|
|
72
|
+
yield _a.removeLocalFolder(key);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
FileStorageHelper.storeLocal = (key, contents) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const fileName = _a.rootPath + key;
|
|
78
|
+
const dirName = path_1.default.dirname(fileName);
|
|
79
|
+
if (!fs_1.default.existsSync(dirName))
|
|
80
|
+
fs_1.default.mkdirSync(dirName, { recursive: true });
|
|
81
|
+
fs_1.default.writeFileSync(fileName, contents);
|
|
82
|
+
});
|
|
83
|
+
FileStorageHelper.moveLocal = (oldKey, newKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
fs_1.default.rename(oldKey, newKey, err => { throw err; });
|
|
85
|
+
});
|
|
86
|
+
FileStorageHelper.removeLocal = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
fs_1.default.unlinkSync(_a.rootPath + key);
|
|
88
|
+
});
|
|
89
|
+
FileStorageHelper.removeLocalFolder = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
fs_1.default.rmdirSync(_a.rootPath + key);
|
|
91
|
+
});
|
|
92
|
+
FileStorageHelper.listLocal = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
const fullPath = _a.rootPath + filePath;
|
|
94
|
+
if (!fs_1.default.existsSync(fullPath))
|
|
95
|
+
return [];
|
|
96
|
+
else
|
|
97
|
+
return fs_1.default.readdirSync(_a.rootPath + filePath);
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=FileStorageHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileStorageHelper.js","sourceRoot":"","sources":["../../src/helpers/FileStorageHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,4CAAoB;AACpB,gDAAwB;AACxB,wBAAoC;AAEpC,MAAa,iBAAiB;;AAA9B,8CAiEC;;AAhEgB,0BAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,GAAG,AAAlC,CAAmC;AAEnD,sBAAI,GAAG,CAAO,QAAgB,EAAE,EAAE;IACvC,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,QAAQ,kBAAe,CAAC,SAAS,EAAE;QACjC,KAAK,IAAI;YAAE,MAAM,GAAG,MAAM,qBAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAAC,MAAM;QAC5D;YAAS,MAAM,GAAG,MAAM,EAAiB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAAC,MAAM;KACtE;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,AAPU,CAOV;AAEM,sBAAI,GAAG,CAAO,MAAc,EAAE,MAAc,EAAE,EAAE;IACrD,QAAQ,kBAAe,CAAC,SAAS,EAAE;QACjC,KAAK,IAAI;YAAE,M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,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AACtF,MAAM,WAAW,aAAa;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/helpers/Interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class LoggingHelper {
|
|
2
|
+
private static _current;
|
|
3
|
+
static getCurrent: () => LoggingHelper;
|
|
4
|
+
private _logger;
|
|
5
|
+
private wc;
|
|
6
|
+
private pendingMessages;
|
|
7
|
+
private logGroupName;
|
|
8
|
+
private logDestination;
|
|
9
|
+
error(msg: string | object): void;
|
|
10
|
+
info(msg: string | object): void;
|
|
11
|
+
log(streamName: string, level: string, msg: string | object): void;
|
|
12
|
+
private init;
|
|
13
|
+
flush(): Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=LoggingHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggingHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/LoggingHelper.ts"],"names":[],"mappings":"AAKA,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuB;IAC9C,OAAc,UAAU,sBAMvB;IAED,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,cAAc,CAAa;IAI5B,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAQ1B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAMzB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAQlE,OAAO,CAAC,IAAI;IAaL,KAAK;CAgBb"}
|