@churchapps/apihelper 0.5.2 → 0.5.4

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.
Files changed (75) hide show
  1. package/dist/auth/CustomAuthProvider.js +1 -1
  2. package/dist/controllers/CustomBaseController.d.ts.map +1 -1
  3. package/dist/controllers/CustomBaseController.js.map +1 -1
  4. package/dist/controllers/ErrorController.d.ts.map +1 -1
  5. package/dist/controllers/ErrorController.js +5 -5
  6. package/dist/controllers/ErrorController.js.map +1 -1
  7. package/dist/helpers/AwsHelper.d.ts.map +1 -1
  8. package/dist/helpers/AwsHelper.js.map +1 -1
  9. package/dist/helpers/BasePermissions.d.ts.map +1 -1
  10. package/dist/helpers/BasePermissions.js +3 -9
  11. package/dist/helpers/BasePermissions.js.map +1 -1
  12. package/dist/helpers/DB.d.ts.map +1 -1
  13. package/dist/helpers/DB.js +0 -1
  14. package/dist/helpers/DB.js.map +1 -1
  15. package/dist/helpers/DBCreator.d.ts.map +1 -1
  16. package/dist/helpers/DBCreator.js.map +1 -1
  17. package/dist/helpers/EmailHelper.d.ts +1 -1
  18. package/dist/helpers/EmailHelper.d.ts.map +1 -1
  19. package/dist/helpers/EmailHelper.js +12 -11
  20. package/dist/helpers/EmailHelper.js.map +1 -1
  21. package/dist/helpers/EncryptionHelper.d.ts.map +1 -1
  22. package/dist/helpers/EncryptionHelper.js +4 -4
  23. package/dist/helpers/EncryptionHelper.js.map +1 -1
  24. package/dist/helpers/EnvironmentBase.d.ts.map +1 -1
  25. package/dist/helpers/EnvironmentBase.js.map +1 -1
  26. package/dist/helpers/FileStorageHelper.d.ts.map +1 -1
  27. package/dist/helpers/FileStorageHelper.js.map +1 -1
  28. package/dist/helpers/LoggingHelper.d.ts.map +1 -1
  29. package/dist/helpers/LoggingHelper.js +1 -1
  30. package/dist/helpers/LoggingHelper.js.map +1 -1
  31. package/dist/helpers/MySqlHelper.d.ts.map +1 -1
  32. package/dist/helpers/MySqlHelper.js.map +1 -1
  33. package/dist/helpers/OmitEmpty.d.ts.map +1 -1
  34. package/dist/helpers/OmitEmpty.js +1 -1
  35. package/dist/helpers/OmitEmpty.js.map +1 -1
  36. package/dist/helpers/Pool.d.ts.map +1 -1
  37. package/dist/helpers/Pool.js +2 -2
  38. package/dist/helpers/Pool.js.map +1 -1
  39. package/dist/helpers/SlugHelper.d.ts.map +1 -1
  40. package/dist/helpers/SlugHelper.js +5 -3
  41. package/dist/helpers/SlugHelper.js.map +1 -1
  42. package/package.json +7 -9
  43. package/.github/FUNDING.yml +0 -1
  44. package/.prettierrc.json +0 -13
  45. package/CLAUDE.md +0 -110
  46. package/eslint.config.mjs +0 -40
  47. package/scripts/copy-assets.js +0 -35
  48. package/src/auth/AuthenticatedUser.ts +0 -44
  49. package/src/auth/CustomAuthProvider.ts +0 -25
  50. package/src/auth/Principal.ts +0 -38
  51. package/src/auth/index.ts +0 -3
  52. package/src/controllers/CustomBaseController.ts +0 -62
  53. package/src/controllers/ErrorController.ts +0 -33
  54. package/src/controllers/index.ts +0 -2
  55. package/src/helpers/AwsHelper.ts +0 -129
  56. package/src/helpers/BasePermissions.ts +0 -15
  57. package/src/helpers/DB.ts +0 -41
  58. package/src/helpers/DBCreator.ts +0 -39
  59. package/src/helpers/EmailHelper.ts +0 -99
  60. package/src/helpers/EncryptionHelper.ts +0 -25
  61. package/src/helpers/EnvironmentBase.ts +0 -36
  62. package/src/helpers/FileStorageHelper.ts +0 -71
  63. package/src/helpers/Interfaces.ts +0 -2
  64. package/src/helpers/LoggingHelper.ts +0 -71
  65. package/src/helpers/MySqlHelper.ts +0 -5
  66. package/src/helpers/OmitEmpty.ts +0 -128
  67. package/src/helpers/Pool.ts +0 -56
  68. package/src/helpers/SlugHelper.ts +0 -37
  69. package/src/helpers/index.ts +0 -17
  70. package/src/index.ts +0 -3
  71. package/src/models/ErrorLog.ts +0 -7
  72. package/src/models/index.ts +0 -1
  73. package/src/tools/templates/ChurchEmailTemplate.html +0 -383
  74. package/src/tools/templates/EmailTemplate.html +0 -424
  75. package/tsconfig.json +0 -26
@@ -1,99 +0,0 @@
1
- import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses';
2
- import nodemailer from 'nodemailer'
3
- // Removed nodemailer-direct-transport due to security vulnerabilities
4
- import { EnvironmentBase } from './EnvironmentBase.js';
5
- import { IEmailPayload } from './Interfaces.js';
6
- import fs from "fs";
7
- import path from "path";
8
- import { fileURLToPath } from "url";
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
-
13
- export class EmailHelper {
14
-
15
- private static getSESClient(): SESClient {
16
- return new SESClient({ region: "us-east-2" });
17
- }
18
-
19
- public static async sendTemplatedEmail(from: string, to: string, appName: string, appUrl: string, subject: string, contents: string, emailTemplate: "EmailTemplate.html" | "ChurchEmailTemplate.html" = "EmailTemplate.html", replyTo?: string) {
20
- if (!appName) appName = "B1";
21
- if (!appUrl) appUrl = "https://b1.church";
22
-
23
- const template = EmailHelper.readTemplate(emailTemplate);
24
- const emailBody = template
25
- .replace("{appLink}", "<a target='_blank' rel='noreferrer noopener' href=\"" + appUrl + "/\">" + appName + "</a>")
26
- .replace("{contents}", contents);
27
- await EmailHelper.sendEmail({ from, to, subject, body: emailBody, replyTo });
28
- }
29
-
30
- public static readTemplate(templateFile?: string) {
31
- if (!templateFile) templateFile = "EmailTemplate.html";
32
- const filePath = path.join(__dirname, "../../src/tools/templates/" + templateFile);
33
- const buffer = fs.readFileSync(filePath);
34
- const contents = buffer.toString();
35
- return contents;
36
- }
37
-
38
- private static async sendSes({ from, to, subject, body, replyTo }: IEmailPayload) {
39
- const sesClient = this.getSESClient();
40
- const sendCommand = new SendEmailCommand({
41
- Destination: {
42
- ToAddresses: [to]
43
- },
44
- Message: {
45
- Body: {
46
- Html: {
47
- Charset: 'UTF-8',
48
- Data: body
49
- }
50
- },
51
- Subject: {
52
- Charset: 'UTF-8',
53
- Data: subject
54
- }
55
- },
56
- Source: from,
57
- ReplyToAddresses: replyTo ? [replyTo] : undefined
58
- });
59
- await sesClient.send(sendCommand);
60
- }
61
-
62
- public static async sendEmail({ from, to, subject, body, replyTo }: IEmailPayload): Promise<void> {
63
- try {
64
- // Use a safer fallback - streamline transport (for testing/dev) or require proper SMTP config
65
- let transporter: nodemailer.Transporter = nodemailer.createTransport({
66
- streamTransport: true,
67
- newline: 'unix',
68
- buffer: true
69
- });
70
-
71
- if (EnvironmentBase.mailSystem === 'SES') {
72
- await this.sendSes({ from, to, subject, body, replyTo });
73
- } else {
74
- if (EnvironmentBase.mailSystem === "SMTP") {
75
- transporter = nodemailer.createTransport({
76
- host: EnvironmentBase.smtpHost,
77
- secure: EnvironmentBase.smtpSecure,
78
- auth: {
79
- user: EnvironmentBase.smtpUser,
80
- pass: EnvironmentBase.smtpPass
81
- }
82
- });
83
- }
84
-
85
- if (EnvironmentBase.mailSystem === "") {
86
- console.log("****Email server not configured: ");
87
- console.log(subject);
88
- console.log(body);
89
- } else {
90
- await transporter.sendMail({ from, to, subject, html: body, replyTo });
91
- }
92
- }
93
- return null;
94
- } catch (err) {
95
- throw err;
96
- }
97
- }
98
-
99
- }
@@ -1,25 +0,0 @@
1
- import crypto from "crypto";
2
- import { EnvironmentBase } from "./EnvironmentBase.js";
3
-
4
- export class EncryptionHelper {
5
- private static algorithm = 'aes-256-ctr';
6
-
7
- static encrypt = (plainValue: string) => {
8
- const iv = crypto.randomBytes(16);
9
- const cipher = crypto.createCipheriv(EncryptionHelper.algorithm, EnvironmentBase.encryptionKey, iv);
10
- const encrypted = Buffer.concat([cipher.update(plainValue), cipher.final()]);
11
- return iv.toString('base64') + "|" + encrypted.toString('base64');
12
- }
13
-
14
- static decrypt = (encryptedPair: string) => {
15
- const parts = encryptedPair.split("|");
16
- if (parts.length !== 2) return "";
17
- else {
18
- const iv = Buffer.from(parts[0], 'base64');
19
- const content = Buffer.from(parts[1], 'base64');
20
- const decipher = crypto.createDecipheriv(EncryptionHelper.algorithm, EnvironmentBase.encryptionKey, iv);
21
- const decrpyted = Buffer.concat([decipher.update(content), decipher.final()]);
22
- return decrpyted.toString();
23
- }
24
- }
25
- }
@@ -1,36 +0,0 @@
1
- import { AwsHelper } from "./AwsHelper.js";
2
-
3
- export class EnvironmentBase {
4
- static appEnv: string;
5
- static appName: string;
6
- static s3Bucket: string;
7
- static connectionString: string;
8
- static contentRoot: string;
9
- static encryptionKey: string;
10
- static fileStore: string;
11
- static jwtSecret: string;
12
-
13
- static mailSystem: string;
14
- static smtpHost: string;
15
- static smtpPass: string;
16
- static smtpSecure: boolean;
17
- static smtpUser: string;
18
-
19
-
20
- static async populateBase(jsonData: Record<string, unknown>, appName:string, appEnv: string) {
21
- EnvironmentBase.appName = jsonData.appName as string;
22
- EnvironmentBase.appEnv = jsonData.appEnv as string;
23
- EnvironmentBase.connectionString = process.env.CONNECTION_STRING || await AwsHelper.readParameter(`/${appEnv}/${appName}/connectionString`);
24
- EnvironmentBase.contentRoot = jsonData.contentRoot as string;
25
- EnvironmentBase.encryptionKey = process.env.ENCRYPTION_KEY || await AwsHelper.readParameter(`/${appEnv}/encryptionKey`);
26
- EnvironmentBase.fileStore = jsonData.fileStore as string;
27
- EnvironmentBase.jwtSecret = process.env.JWT_SECRET || await AwsHelper.readParameter(`/${appEnv}/jwtSecret`);
28
- EnvironmentBase.mailSystem = jsonData.mailSystem as string;
29
- EnvironmentBase.s3Bucket = jsonData.s3Bucket as string;
30
- EnvironmentBase.smtpHost = process.env.SMTP_HOST;
31
- EnvironmentBase.smtpPass = process.env.SMTP_PASS;
32
- EnvironmentBase.smtpSecure = process.env.SMTP_SECURE === "true";
33
- EnvironmentBase.smtpUser = process.env.SMTP_USER;
34
- }
35
-
36
- }
@@ -1,71 +0,0 @@
1
- import { AwsHelper } from "./AwsHelper.js";
2
- import fs from "fs";
3
- import path from "path";
4
- import { EnvironmentBase } from "./EnvironmentBase.js";
5
-
6
- export class FileStorageHelper {
7
- private static rootPath = path.resolve("./content") + "/";
8
-
9
- static list = async (filePath: string) => {
10
- let result = []
11
- switch (EnvironmentBase.fileStore) {
12
- case "S3": result = await AwsHelper.S3List(filePath); break;
13
- default: result = await FileStorageHelper.listLocal(filePath); break;
14
- }
15
- return result
16
- }
17
-
18
- static move = async (oldKey: string, newKey: string) => {
19
- switch (EnvironmentBase.fileStore) {
20
- case "S3": await AwsHelper.S3Move(oldKey, newKey); break;
21
- default: await FileStorageHelper.moveLocal(oldKey, newKey); break;
22
- }
23
- }
24
-
25
- static store = async (key: string, contentType: string, contents: Buffer) => {
26
- switch (EnvironmentBase.fileStore) {
27
- case "S3": await AwsHelper.S3Upload(key, contentType, contents); break;
28
- default: await FileStorageHelper.storeLocal(key, contents); break;
29
- }
30
- }
31
-
32
- static remove = async (key: string) => {
33
- switch (EnvironmentBase.fileStore) {
34
- case "S3": await AwsHelper.S3Remove(key); break;
35
- default: await FileStorageHelper.removeLocal(key); break;
36
- }
37
- }
38
-
39
- static removeFolder = async (key: string) => {
40
- switch (EnvironmentBase.fileStore) {
41
- case "S3": break; // no need on s3
42
- default: await FileStorageHelper.removeLocalFolder(key); break;
43
- }
44
- }
45
-
46
- private static storeLocal = async (key: string, contents: Buffer) => {
47
- const fileName = FileStorageHelper.rootPath + key;
48
- const dirName = path.dirname(fileName);
49
- if (!fs.existsSync(dirName)) fs.mkdirSync(dirName, { recursive: true });
50
- fs.writeFileSync(fileName, contents);
51
- }
52
-
53
- private static moveLocal = async (oldKey: string, newKey: string) => {
54
- fs.rename(oldKey, newKey, err => { throw err; });
55
- }
56
-
57
- private static removeLocal = async (key: string) => {
58
- fs.unlinkSync(FileStorageHelper.rootPath + key);
59
- }
60
-
61
- private static removeLocalFolder = async (key: string) => {
62
- fs.rmdirSync(FileStorageHelper.rootPath + key);
63
- }
64
-
65
- private static listLocal = async (filePath: string) => {
66
- const fullPath = FileStorageHelper.rootPath + filePath;
67
- if (!fs.existsSync(fullPath)) return [];
68
- else return fs.readdirSync(FileStorageHelper.rootPath + filePath);
69
- }
70
-
71
- }
@@ -1,2 +0,0 @@
1
- export interface IPermission { contentType: string; action: string; apiName?: string }
2
- export interface IEmailPayload { from: string, to: string, subject: string, body: string, replyTo?: string }
@@ -1,71 +0,0 @@
1
- import winston from "winston";
2
- import WinstonCloudWatch from "winston-cloudwatch";
3
- //import AWS from "aws-sdk";
4
- import { EnvironmentBase } from "./EnvironmentBase.js";
5
-
6
- export class LoggingHelper {
7
- private static _current: LoggingHelper = null;
8
- public static getCurrent = () => {
9
- if (LoggingHelper._current === null) {
10
- LoggingHelper._current = new LoggingHelper();
11
- LoggingHelper._current.init("API");
12
- }
13
- return LoggingHelper._current;
14
- }
15
-
16
- private _logger: winston.Logger = null;
17
- private wc: WinstonCloudWatch;
18
- private pendingMessages = false;
19
- private logGroupName = EnvironmentBase.appName + "_" + EnvironmentBase.appEnv;
20
- private logDestination = "console";
21
-
22
-
23
-
24
- public error(msg: string | object) {
25
- throw msg instanceof Error ? msg : new Error(typeof msg === 'string' ? msg : JSON.stringify(msg));
26
- }
27
-
28
- public info(msg: string | object) {
29
- if (this._logger === null) this.init("API");
30
- this.pendingMessages = true;
31
- this._logger.info(msg);
32
- }
33
-
34
- public log(streamName: string, level: string, msg: string | object) {
35
- if (this._logger === null) this.init(streamName);
36
- this.pendingMessages = true;
37
- if (level === "info") this._logger.info(msg);
38
- else this._logger.error(msg);
39
- }
40
-
41
-
42
- private init(streamName: string) {
43
- this.pendingMessages = false;
44
- //AWS.config.update({ region: "us-east-2" });
45
- if (EnvironmentBase.appEnv === "staging") this.logDestination = "cloudwatch";
46
- else if (EnvironmentBase.appEnv === "prod") this.logDestination = "cloudwatch";
47
-
48
- if (this.logDestination === "cloudwatch") {
49
- this.wc = new WinstonCloudWatch({ logGroupName: this.logGroupName, logStreamName: streamName, name: this.logGroupName + "_" + streamName });
50
- this._logger = winston.createLogger({ transports: [this.wc], format: winston.format.json() });
51
- } else this._logger = winston.createLogger({ transports: [new winston.transports.Console()], format: winston.format.json() });
52
- this._logger.info("Logger initialized");
53
- }
54
-
55
- public flush() {
56
- const promise = new Promise((resolve) => {
57
- if (this.pendingMessages) {
58
- if (this.wc) {
59
- this.wc.kthxbye(() => {
60
- // this._logger = null;
61
- this.pendingMessages = false;
62
- });
63
- }
64
- resolve(null);
65
- } else resolve(null);
66
- });
67
- return promise;
68
- }
69
-
70
-
71
- }
@@ -1,5 +0,0 @@
1
- export class MySqlHelper {
2
- static toQuotedAndCommaSeparatedString(values: string[]) {
3
- return values.length === 0 ? "" : "'" + values.join("','") + "'";
4
- }
5
- }
@@ -1,128 +0,0 @@
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
-
4
- "use strict";
5
-
6
-
7
- interface OmitEmptyOptions {
8
- omitZero?: boolean;
9
- omitEmptyArray?: boolean;
10
- excludedProperties?: string[];
11
- }
12
-
13
- interface RuntimeOptions {
14
- omitZero: boolean;
15
- omitEmptyArray: boolean;
16
- excludedProperties: string[];
17
- }
18
-
19
- export class OmitEmpty {
20
- public static omitEmpty(obj: unknown, options: OmitEmptyOptions = {}): unknown {
21
- const runtimeOpts = OmitEmpty._buildRuntimeOpts(options);
22
-
23
- const omit = (value: unknown, opts: RuntimeOptions): unknown => {
24
- if (Array.isArray(value)) {
25
- value = value.map(v => omit(v, opts)).filter(v => !OmitEmpty.isEmpty(v, opts));
26
- }
27
-
28
- if (OmitEmpty.getType(value) === "object" && value !== null) {
29
- const result: Record<string, unknown> = {};
30
- for (const key of Object.keys(value as Record<string, unknown>)) {
31
- if (!opts.excludedProperties.includes(key)) {
32
- const val = omit((value as Record<string, unknown>)[key], opts);
33
- if (val !== void 0) {
34
- result[key] = val;
35
- }
36
- }
37
- }
38
- value = result;
39
- }
40
-
41
- if (!OmitEmpty.isEmpty(value, opts)) {
42
- return value;
43
- }
44
- };
45
-
46
- const res = omit(obj, runtimeOpts);
47
- if (res === void 0) {
48
- return OmitEmpty.getType(obj) === "object" ? {} : res;
49
- }
50
- return res;
51
- }
52
-
53
-
54
- private static _buildRuntimeOpts(options: OmitEmptyOptions = {}): RuntimeOptions {
55
- return {
56
- omitZero: options.omitZero || false,
57
- omitEmptyArray: options.omitEmptyArray || false,
58
- excludedProperties: options.excludedProperties || []
59
- };
60
- };
61
-
62
- private static getType(value: unknown): string {
63
- if (value === null) return "null";
64
- if (value === undefined) return "undefined";
65
- if (Array.isArray(value)) return "array";
66
- if (value instanceof Date) return "date";
67
- if (value instanceof RegExp) return "regexp";
68
- if (value instanceof Error) return "error";
69
- if (value instanceof Map) return "map";
70
- if (value instanceof Set) return "set";
71
- if (value instanceof File) return "file";
72
-
73
- const type = typeof value;
74
- if (type === "object") {
75
- // Check if it's an arguments object
76
- if (Object.prototype.toString.call(value) === '[object Arguments]') {
77
- return "arguments";
78
- }
79
- }
80
- return type;
81
- }
82
-
83
- private static isEmpty(value: unknown, runtimeOpts: RuntimeOptions): boolean {
84
- switch (OmitEmpty.getType(value)) {
85
- case "null":
86
- case "undefined":
87
- return true;
88
- case "boolean":
89
- case "function":
90
- case "date":
91
- case "regexp":
92
- return false;
93
- case "string":
94
- case "arguments":
95
- return (value as string).length === 0;
96
- case "file":
97
- case "map":
98
- case "set":
99
- return (value as { size: number }).size === 0;
100
- case "number":
101
- return runtimeOpts.omitZero ? value === 0 : false;
102
- case "error":
103
- return (value as Error).message === "";
104
- case "array":
105
- if (runtimeOpts.omitEmptyArray) {
106
- for (const ele of (value as unknown[])) {
107
- if (!OmitEmpty.isEmpty(ele, runtimeOpts)) {
108
- return false;
109
- }
110
- }
111
- return true;
112
- } else {
113
- return false;
114
- }
115
- case "object":
116
- for (const key of Object.keys(value as Record<string, unknown>)) {
117
- if (!OmitEmpty.isEmpty((value as Record<string, unknown>)[key], runtimeOpts)) {
118
- return false;
119
- }
120
- }
121
- return true;
122
- default: {
123
- return true;
124
- }
125
- }
126
- }
127
-
128
- }
@@ -1,56 +0,0 @@
1
- import dotenv from "dotenv";
2
- import mysql from "mysql2";
3
- import { EnvironmentBase } from "./EnvironmentBase.js";
4
-
5
- dotenv.config();
6
-
7
- export class Pool {
8
- public static current: mysql.Pool;
9
-
10
- public static initPool() {
11
- const config = this.getConfig(EnvironmentBase.connectionString);
12
-
13
- Pool.current = mysql.createPool({
14
- connectionLimit: 3,
15
- host: config.host,
16
- port: config.port,
17
- database: config.database,
18
- user: config.userName,
19
- password: config.password,
20
- multipleStatements: true,
21
- waitForConnections: true,
22
- queueLimit: 9999,
23
- charset: 'utf8mb4',
24
- typeCast: function castField(field: mysql.Field, useDefaultTypeCasting: () => unknown) {
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
- } catch { return false; }
31
- }
32
- return useDefaultTypeCasting();
33
- }
34
- });
35
- }
36
-
37
- // a bit of a hack
38
- private static getConfig = (connectionString: string) => {
39
- // mysql://user:password@host:port/dbName
40
- const firstSplit = connectionString.replace("mysql://", "").split("@");
41
- const userPass = firstSplit[0].split(":");
42
- const userName = userPass[0];
43
- const password = userPass[1];
44
-
45
- const hostDb = firstSplit[1].split("/");
46
- const database = hostDb[1];
47
- const hostPort = hostDb[0].split(':');
48
- const host = hostPort[0];
49
- const port = parseInt(hostPort[1], 0)
50
-
51
- return { host, port, database, userName, password }
52
-
53
- }
54
-
55
- }
56
-
@@ -1,37 +0,0 @@
1
-
2
- export class SlugHelper {
3
-
4
- static slugifyString(string: string, removeCharacters?: string[]) {
5
- const charactersToRemove = removeCharacters ? removeCharacters : ["for", "and", "nor", "but", "or", "yet", "so", "the", "a", "an"];
6
- const characStr = charactersToRemove.join("|");
7
- const regex = new RegExp('\\b(' + characStr + ')\\b', 'gi')
8
- const cleaned = string.replace(regex, '');
9
-
10
- const initialSlug = cleaned.replace(/ /g, "-").toLowerCase();
11
- const verfiedSlug = this.numerifySlug(initialSlug);
12
- return verfiedSlug;
13
- }
14
-
15
- //remove multiple numbers in sequence
16
- static numerifySlug(slug: string) {
17
- let initialString = slug;
18
- const regex = /\d+(?:-\d+)+|\d+/g;
19
- const matchedArray = initialString.match(regex);
20
-
21
- if (matchedArray) {
22
- matchedArray.forEach((data) => {
23
- const length = data.length;
24
- let splitResult = data;
25
- if (length > 1) {
26
- const array = data.split("");
27
- splitResult = array[0];
28
- }
29
- const replacedString = initialString.replace(data, splitResult);
30
- initialString = replacedString;
31
- });
32
- }
33
-
34
- return initialString;
35
- }
36
-
37
- }
@@ -1,17 +0,0 @@
1
- export * from "@churchapps/helpers";
2
-
3
- // Export all local helpers
4
- export * from "./AwsHelper.js";
5
- export * from "./DB.js";
6
- export * from "./DBCreator.js";
7
- export * from "./EncryptionHelper.js";
8
- export * from "./EnvironmentBase.js";
9
- export * from "./FileStorageHelper.js";
10
- export * from "./Interfaces.js";
11
- export * from "./LoggingHelper.js";
12
- export * from "./OmitEmpty.js";
13
- export * from "./BasePermissions.js";
14
- export * from "./EmailHelper.js";
15
- export * from "./MySqlHelper.js";
16
- export * from "./Pool.js";
17
- export * from "./SlugHelper.js";
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./helpers/index.js";
2
- export * from "./auth/index.js";
3
- export * from "./controllers/index.js";
@@ -1,7 +0,0 @@
1
-
2
- export class ErrorLog {
3
- public application?: string;
4
- public level?: string;
5
- public message?: string;
6
- public additionalDetails?: string;
7
- }
@@ -1 +0,0 @@
1
- export { ErrorLog } from "./ErrorLog.js";