@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,83 @@
|
|
|
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.LoggingHelper = void 0;
|
|
7
|
+
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
const winston_cloudwatch_1 = __importDefault(require("winston-cloudwatch"));
|
|
9
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
10
|
+
const _1 = require(".");
|
|
11
|
+
class LoggingHelper {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._logger = null;
|
|
14
|
+
this.pendingMessages = false;
|
|
15
|
+
this.logGroupName = _1.EnvironmentBase.appName + "_" + _1.EnvironmentBase.appEnv;
|
|
16
|
+
this.logDestination = "console";
|
|
17
|
+
}
|
|
18
|
+
error(msg) {
|
|
19
|
+
if (this._logger === null)
|
|
20
|
+
this.init("API");
|
|
21
|
+
this.pendingMessages = true;
|
|
22
|
+
if (_1.EnvironmentBase.appEnv === "dev")
|
|
23
|
+
console.log(msg);
|
|
24
|
+
this._logger.error(msg);
|
|
25
|
+
this._logger.error(new Error().stack.toString());
|
|
26
|
+
}
|
|
27
|
+
info(msg) {
|
|
28
|
+
if (this._logger === null)
|
|
29
|
+
this.init("API");
|
|
30
|
+
this.pendingMessages = true;
|
|
31
|
+
this._logger.info(msg);
|
|
32
|
+
}
|
|
33
|
+
log(streamName, level, msg) {
|
|
34
|
+
if (this._logger === null)
|
|
35
|
+
this.init(streamName);
|
|
36
|
+
this.pendingMessages = true;
|
|
37
|
+
if (level === "info")
|
|
38
|
+
this._logger.info(msg);
|
|
39
|
+
else
|
|
40
|
+
this._logger.error(msg);
|
|
41
|
+
}
|
|
42
|
+
init(streamName) {
|
|
43
|
+
this.pendingMessages = false;
|
|
44
|
+
aws_sdk_1.default.config.update({ region: "us-east-2" });
|
|
45
|
+
if (_1.EnvironmentBase.appEnv === "staging")
|
|
46
|
+
this.logDestination = "cloudwatch";
|
|
47
|
+
else if (_1.EnvironmentBase.appEnv === "prod")
|
|
48
|
+
this.logDestination = "cloudwatch";
|
|
49
|
+
if (this.logDestination === "cloudwatch") {
|
|
50
|
+
this.wc = new winston_cloudwatch_1.default({ logGroupName: this.logGroupName, logStreamName: streamName, name: this.logGroupName + "_" + streamName });
|
|
51
|
+
this._logger = winston_1.default.createLogger({ transports: [this.wc], format: winston_1.default.format.json(), });
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
this._logger = winston_1.default.createLogger({ transports: [new winston_1.default.transports.Console()], format: winston_1.default.format.json() });
|
|
55
|
+
this._logger.info("Logger initialized");
|
|
56
|
+
}
|
|
57
|
+
flush() {
|
|
58
|
+
const promise = new Promise((resolve) => {
|
|
59
|
+
if (this.pendingMessages) {
|
|
60
|
+
if (this.wc) {
|
|
61
|
+
this.wc.kthxbye(() => {
|
|
62
|
+
// this._logger = null;
|
|
63
|
+
this.pendingMessages = false;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
resolve(null);
|
|
67
|
+
}
|
|
68
|
+
else
|
|
69
|
+
resolve(null);
|
|
70
|
+
});
|
|
71
|
+
return promise;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.LoggingHelper = LoggingHelper;
|
|
75
|
+
LoggingHelper._current = null;
|
|
76
|
+
LoggingHelper.getCurrent = () => {
|
|
77
|
+
if (LoggingHelper._current === null) {
|
|
78
|
+
LoggingHelper._current = new LoggingHelper();
|
|
79
|
+
LoggingHelper._current.init("API");
|
|
80
|
+
}
|
|
81
|
+
return LoggingHelper._current;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=LoggingHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggingHelper.js","sourceRoot":"","sources":["../../src/helpers/LoggingHelper.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,4EAAmD;AACnD,sDAA0B;AAC1B,wBAAoC;AAEpC,MAAa,aAAa;IAA1B;QAUU,YAAO,GAAmB,IAAI,CAAC;QAE/B,oBAAe,GAAG,KAAK,CAAC;QACxB,iBAAY,GAAG,kBAAe,CAAC,OAAO,GAAG,GAAG,GAAG,kBAAe,CAAC,MAAM,CAAC;QACtE,mBAAc,GAAG,SAAS,CAAC;IAuDrC,CAAC;IAnDQ,KAAK,CAAC,GAAoB;QAC/B,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,kBAAe,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,CAAC;IAEM,IAAI,CAAC,GAAoB;QAC9B,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAEM,GAAG,CAAC,UAAkB,EAAE,KAAa,EAAE,GAAoB;QAChE,IAAI,IA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AAC;QAC9H,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC1C,CAAC;IAEM,KAAK;QACV,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtC,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,IAAI,IAAI,CAAC,EAAE,EAAE;oBACX,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;wBACnB,uBAAuB;wBACvB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;oBAC/B,CAAC,CAAC,CAAC;iBACJ;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC;aACf;;gBAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;;AAlEH,sCAqEC;AApEgB,sBAAQ,GAAkB,IAAI,AAAtB,CAAuB;AAChC,wBAAU,GAAG,GAAG,EAAE;IAC9B,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI,EAAE;QACnC,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QAC7C,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpC;IACD,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CAAC,AANuB,CAMvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySqlHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/MySqlHelper.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACpB,MAAM,CAAC,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE;CAG1D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MySqlHelper = void 0;
|
|
4
|
+
class MySqlHelper {
|
|
5
|
+
static toQuotedAndCommaSeparatedString(values) {
|
|
6
|
+
return values.length === 0 ? "" : "'" + values.join("','") + "'";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MySqlHelper = MySqlHelper;
|
|
10
|
+
//# sourceMappingURL=MySqlHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySqlHelper.js","sourceRoot":"","sources":["../../src/helpers/MySqlHelper.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACpB,MAAM,CAAC,+BAA+B,CAAC,MAAgB;QACnD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IACrE,CAAC;CACJ;AAJD,kCAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OmitEmpty.d.ts","sourceRoot":"","sources":["../../src/helpers/OmitEmpty.ts"],"names":[],"mappings":"AAQA,qBAAa,SAAS;WACJ,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,KAAK;IAkC9C,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC,OAAO,CAAC,MAAM,CAAC,OAAO;CA6CzB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Based on https://www.npmjs.com/package/omit-empty
|
|
2
|
+
// The project appears to be abandoned, but needed modification to allow for empty arrays.
|
|
3
|
+
"use strict";
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.OmitEmpty = void 0;
|
|
9
|
+
const kind_of_1 = __importDefault(require("kind-of"));
|
|
10
|
+
class OmitEmpty {
|
|
11
|
+
static omitEmpty(obj, options = {}) {
|
|
12
|
+
const runtimeOpts = OmitEmpty._buildRuntimeOpts(options);
|
|
13
|
+
const omit = (value, opts) => {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
value = value.map(v => omit(v, opts)).filter(v => !OmitEmpty.isEmpty(v, opts));
|
|
16
|
+
}
|
|
17
|
+
if ((0, kind_of_1.default)(value) === "object") {
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const key of Object.keys(value)) {
|
|
20
|
+
if (!opts.excludedProperties.includes(key)) {
|
|
21
|
+
const val = omit(value[key], opts);
|
|
22
|
+
if (val !== void 0) {
|
|
23
|
+
result[key] = val;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
value = result;
|
|
28
|
+
}
|
|
29
|
+
if (!OmitEmpty.isEmpty(value, opts)) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const res = omit(obj, runtimeOpts);
|
|
34
|
+
if (res === void 0) {
|
|
35
|
+
return (0, kind_of_1.default)(obj) === "object" ? {} : res;
|
|
36
|
+
}
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
static _buildRuntimeOpts(options = {}) {
|
|
40
|
+
return {
|
|
41
|
+
omitZero: options.omitZero || false,
|
|
42
|
+
omitEmptyArray: options.omitEmptyArray || false,
|
|
43
|
+
excludedProperties: options.excludedProperties || []
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
;
|
|
47
|
+
static isEmpty(value, runtimeOpts) {
|
|
48
|
+
switch ((0, kind_of_1.default)(value)) {
|
|
49
|
+
case "null":
|
|
50
|
+
case "undefined":
|
|
51
|
+
return true;
|
|
52
|
+
case "boolean":
|
|
53
|
+
case "function":
|
|
54
|
+
case "date":
|
|
55
|
+
case "regexp":
|
|
56
|
+
return false;
|
|
57
|
+
case "string":
|
|
58
|
+
case "arguments":
|
|
59
|
+
return value.length === 0;
|
|
60
|
+
case "file":
|
|
61
|
+
case "map":
|
|
62
|
+
case "set":
|
|
63
|
+
return value.size === 0;
|
|
64
|
+
case "number":
|
|
65
|
+
return runtimeOpts.omitZero ? value === 0 : false;
|
|
66
|
+
case "error":
|
|
67
|
+
return value.message === "";
|
|
68
|
+
case "array":
|
|
69
|
+
if (runtimeOpts.omitEmptyArray) {
|
|
70
|
+
for (const ele of value) {
|
|
71
|
+
if (!OmitEmpty.isEmpty(ele, runtimeOpts)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
case "object":
|
|
81
|
+
for (const key of Object.keys(value)) {
|
|
82
|
+
if (!OmitEmpty.isEmpty(value[key], runtimeOpts)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
default: {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.OmitEmpty = OmitEmpty;
|
|
94
|
+
//# sourceMappingURL=OmitEmpty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OmitEmpty.js","sourceRoot":"","sources":["../../src/helpers/OmitEmpty.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,0FAA0F;AAE1F,YAAY,CAAC;;;;;;AAEb,sDAA6B;AAG7B,MAAa,SAAS;IACX,MAAM,CAAC,SAAS,CAAC,GAAQ,EAAE,OAAO,GAAG,EAAE;QAC1C,MAAM,WAAW,GAAG,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEzD,MAAM,IAAI,GAAG,CAAC,KAAU,EAAE,IAAS,EAAE,EAAE;YACnC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACtB,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,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f;SACJ;IACL,CAAC;CAEJ;AAxFD,8BAwFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pool.d.ts","sourceRoot":"","sources":["../../src/helpers/Pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,qBAAa,IAAI;IACf,OAAc,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC;WAEpB,QAAQ;IA2BtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAevB;CAEF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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.Pool = void 0;
|
|
7
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
+
const mysql_1 = __importDefault(require("mysql"));
|
|
9
|
+
const _1 = require(".");
|
|
10
|
+
dotenv_1.default.config();
|
|
11
|
+
class Pool {
|
|
12
|
+
static initPool() {
|
|
13
|
+
const config = this.getConfig(_1.EnvironmentBase.connectionString);
|
|
14
|
+
Pool.current = mysql_1.default.createPool({
|
|
15
|
+
connectionLimit: 3,
|
|
16
|
+
host: config.host,
|
|
17
|
+
port: config.port,
|
|
18
|
+
database: config.database,
|
|
19
|
+
user: config.userName,
|
|
20
|
+
password: config.password,
|
|
21
|
+
multipleStatements: true,
|
|
22
|
+
waitForConnections: true,
|
|
23
|
+
queueLimit: 9999,
|
|
24
|
+
typeCast: function castField(field, useDefaultTypeCasting) {
|
|
25
|
+
// convert bit(1) to bool
|
|
26
|
+
if ((field.type === "BIT") && (field.length === 1)) {
|
|
27
|
+
try {
|
|
28
|
+
const bytes = field.buffer();
|
|
29
|
+
return (bytes[0] === 1);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (useDefaultTypeCasting());
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Pool = Pool;
|
|
41
|
+
// a bit of a hack
|
|
42
|
+
Pool.getConfig = (connectionString) => {
|
|
43
|
+
// mysql://user:password@host:port/dbName
|
|
44
|
+
const firstSplit = connectionString.replace("mysql://", "").split("@");
|
|
45
|
+
const userPass = firstSplit[0].split(":");
|
|
46
|
+
const userName = userPass[0];
|
|
47
|
+
const password = userPass[1];
|
|
48
|
+
const hostDb = firstSplit[1].split("/");
|
|
49
|
+
const database = hostDb[1];
|
|
50
|
+
const hostPort = hostDb[0].split(':');
|
|
51
|
+
const host = hostPort[0];
|
|
52
|
+
const port = parseInt(hostPort[1], 0);
|
|
53
|
+
return { host, port, database, userName, password };
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=Pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pool.js","sourceRoot":"","sources":["../../src/helpers/Pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,kDAA0B;AAC1B,wBAAoC;AAEpC,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAa,IAAI;IAGR,MAAM,CAAC,QAAQ;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,kBAAe,CAAC,gBAAgB,CAAC,CAAC;QAEhE,IAAI,CAAC,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC;YAC9B,eAAe,EAAE,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,kBAAkB,EAAE,IAAI;YACxB,kBAAkB,EAAE,IAAI;YACxB,UAAU,E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C,EAAE,CAAC,CAAC,CAAA;IAErC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;AAErD,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "@churchapps/helpers";
|
|
2
|
+
export * from "./AwsHelper";
|
|
3
|
+
export * from "./DB";
|
|
4
|
+
export * from "./DBCreator";
|
|
5
|
+
export * from "./EncryptionHelper";
|
|
6
|
+
export * from "./EnvironmentBase";
|
|
7
|
+
export * from "./FileStorageHelper";
|
|
8
|
+
export * from "./Interfaces";
|
|
9
|
+
export * from "./LoggingHelper";
|
|
10
|
+
export * from "./OmitEmpty";
|
|
11
|
+
export * from "./BasePermissions";
|
|
12
|
+
export * from "./EmailHelper";
|
|
13
|
+
export * from "./MySqlHelper";
|
|
14
|
+
export * from "./Pool";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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("@churchapps/helpers"), exports);
|
|
18
|
+
__exportStar(require("./AwsHelper"), exports);
|
|
19
|
+
__exportStar(require("./DB"), exports);
|
|
20
|
+
__exportStar(require("./DBCreator"), exports);
|
|
21
|
+
__exportStar(require("./EncryptionHelper"), exports);
|
|
22
|
+
__exportStar(require("./EnvironmentBase"), exports);
|
|
23
|
+
__exportStar(require("./FileStorageHelper"), exports);
|
|
24
|
+
__exportStar(require("./Interfaces"), exports);
|
|
25
|
+
__exportStar(require("./LoggingHelper"), exports);
|
|
26
|
+
__exportStar(require("./OmitEmpty"), exports);
|
|
27
|
+
__exportStar(require("./BasePermissions"), exports);
|
|
28
|
+
__exportStar(require("./EmailHelper"), exports);
|
|
29
|
+
__exportStar(require("./MySqlHelper"), exports);
|
|
30
|
+
__exportStar(require("./Pool"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,8CAA4B;AAC5B,uCAAqB;AACrB,8CAA4B;AAC5B,qDAAmC;AACnC,oDAAkC;AAClC,sDAAoC;AACpC,+CAA6B;AAC7B,kDAAgC;AAChC,8CAA4B;AAC5B,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,yCAAsB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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("./helpers"), exports);
|
|
18
|
+
__exportStar(require("./auth"), exports);
|
|
19
|
+
__exportStar(require("./controllers"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,yCAAuB;AACvB,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorLog.d.ts","sourceRoot":"","sources":["../../src/models/ErrorLog.ts"],"names":[],"mappings":"AACA,qBAAa,QAAQ;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorLog.js","sourceRoot":"","sources":["../../src/models/ErrorLog.ts"],"names":[],"mappings":";;;AACA,MAAa,QAAQ;CAKpB;AALD,4BAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorLog = void 0;
|
|
4
|
+
var ErrorLog_1 = require("./ErrorLog");
|
|
5
|
+
Object.defineProperty(exports, "ErrorLog", { enumerable: true, get: function () { return ErrorLog_1.ErrorLog; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DBCreator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DBCreator.d.ts","sourceRoot":"","sources":["../../src/tools/DBCreator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=DBCreator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DBCreator.js","sourceRoot":"","sources":["../../src/tools/DBCreator.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@churchapps/apihelper",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Library of helper functions not specific to any one ChurchApps project or framework.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"clean": "rimraf dist",
|
|
9
|
+
"copy-assets": "copyfiles -f src/apiBase/tools/templates/* dist/templates",
|
|
10
|
+
"link": "link",
|
|
11
|
+
"tsc": "tsc",
|
|
12
|
+
"build": "npm-run-all clean tsc copy-assets"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/LiveChurchSolutions/Helpers.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"ChurchApps"
|
|
20
|
+
],
|
|
21
|
+
"author": "ChurchApps.org",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/LiveChurchSolutions/Helpers/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/LiveChurchSolutions/Helpers#readme",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@churchapps/helpers": "^1.0.6",
|
|
29
|
+
"aws-sdk": "^2.1445.0",
|
|
30
|
+
"date-fns": "^2.30.0",
|
|
31
|
+
"dotenv": "^16.3.1",
|
|
32
|
+
"express": "^4.17.2",
|
|
33
|
+
"inversify": "^6.0.1",
|
|
34
|
+
"inversify-express-utils": "^6.4.3",
|
|
35
|
+
"jsonwebtoken": "^9.0.1",
|
|
36
|
+
"kind-of": "^6.0.3",
|
|
37
|
+
"mysql": "^2.18.1",
|
|
38
|
+
"nodemailer": "^6.7.2",
|
|
39
|
+
"nodemailer-direct-transport": "^3.3.2",
|
|
40
|
+
"react-ga4": "^2.1.0",
|
|
41
|
+
"rrule": "^2.7.2",
|
|
42
|
+
"winston": "^3.10.0",
|
|
43
|
+
"winston-cloudwatch": "^6.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/express": "^4.17.13",
|
|
47
|
+
"@types/fs-extra": "^9.0.13",
|
|
48
|
+
"@types/jsonwebtoken": "^9.0.2",
|
|
49
|
+
"@types/kind-of": "^6.0.0",
|
|
50
|
+
"@types/mysql": "^2.15.21",
|
|
51
|
+
"@types/node": "^20.5.6",
|
|
52
|
+
"@types/nodemailer": "^6.4.4",
|
|
53
|
+
"@types/nodemailer-direct-transport": "^1.0.32",
|
|
54
|
+
"copyfiles": "^2.4.1",
|
|
55
|
+
"fs-extra": "^10.0.0",
|
|
56
|
+
"npm-run-all": "^4.1.5",
|
|
57
|
+
"rimraf": "^5.0.1",
|
|
58
|
+
"typescript": "^5.2.2"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Principal } from "./"
|
|
2
|
+
import { IPermission } from "../helpers/Interfaces";
|
|
3
|
+
|
|
4
|
+
export class AuthenticatedUser {
|
|
5
|
+
public id: string;
|
|
6
|
+
public churchId: string;
|
|
7
|
+
public email: string;
|
|
8
|
+
public apiName: string;
|
|
9
|
+
public permissions: string[];
|
|
10
|
+
public personId: string;
|
|
11
|
+
public firstName: string;
|
|
12
|
+
public lastName: string;
|
|
13
|
+
public membershipStatus?: string;
|
|
14
|
+
public groupIds?: string[];
|
|
15
|
+
|
|
16
|
+
public constructor(principal: Principal) {
|
|
17
|
+
this.id = principal.details.id;
|
|
18
|
+
this.churchId = principal.details.churchId;
|
|
19
|
+
this.permissions = principal.details.permissions;
|
|
20
|
+
this.apiName = principal.details.apiName;
|
|
21
|
+
this.email = principal.details.email;
|
|
22
|
+
this.personId = principal.details.personId;
|
|
23
|
+
this.firstName = principal.details.firstName;
|
|
24
|
+
this.lastName = principal.details.lastName;
|
|
25
|
+
this.membershipStatus = principal.details.membershipStatus;
|
|
26
|
+
this.groupIds = principal.details.groupIds;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public checkAccess(permission: IPermission) {
|
|
30
|
+
const key = (permission.apiName)
|
|
31
|
+
? permission.apiName + "_" + permission.contentType + "__" + permission.action
|
|
32
|
+
: permission.contentType + "__" + permission.action;
|
|
33
|
+
|
|
34
|
+
let result = false;
|
|
35
|
+
this.permissions?.forEach((p: string) => {
|
|
36
|
+
if (p === key) result = true;
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { injectable } from "inversify";
|
|
2
|
+
import { interfaces } from "inversify-express-utils";
|
|
3
|
+
import express from "express";
|
|
4
|
+
import jwt from "jsonwebtoken";
|
|
5
|
+
import { Principal } from "./";
|
|
6
|
+
import { EnvironmentBase } from "..";
|
|
7
|
+
|
|
8
|
+
@injectable()
|
|
9
|
+
export class CustomAuthProvider implements interfaces.AuthProvider {
|
|
10
|
+
// public async getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<interfaces.Principal> {
|
|
11
|
+
public async getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<Principal> {
|
|
12
|
+
const authHeader = req.headers.authorization;
|
|
13
|
+
if (authHeader) {
|
|
14
|
+
const token = authHeader.split(" ")[1];
|
|
15
|
+
if (!token) return null;
|
|
16
|
+
const decoded = jwt.verify(token, EnvironmentBase.jwtSecret);
|
|
17
|
+
|
|
18
|
+
return decoded ? new Principal(decoded) : null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { interfaces } from "inversify-express-utils";
|
|
2
|
+
|
|
3
|
+
export class Principal implements interfaces.Principal {
|
|
4
|
+
public details: any;
|
|
5
|
+
|
|
6
|
+
public constructor(details: any) {
|
|
7
|
+
this.details = details;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public isAuthenticated(): Promise<boolean> {
|
|
11
|
+
return Promise.resolve(true);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public isResourceOwner(resourceId: any): Promise<boolean> {
|
|
15
|
+
return Promise.resolve(resourceId === 1111);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public isInRole(role: string): Promise<boolean> {
|
|
19
|
+
return Promise.resolve(role === "admin");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|