pg-mvc-service 2.0.26 → 2.0.28
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/dist/cron/BaseCron.js +19 -0
- package/dist/cron/CronExecuter.js +1 -1
- package/package.json +1 -1
- package/src/cron/BaseCron.ts +23 -0
- package/src/cron/CronExecuter.ts +1 -1
package/dist/cron/BaseCron.js
CHANGED
|
@@ -14,6 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BaseCron = void 0;
|
|
16
16
|
const PoolManager_1 = __importDefault(require("../PoolManager"));
|
|
17
|
+
const AwsS3Client_1 = require("../clients/AwsS3Client");
|
|
18
|
+
const Base64Client_1 = require("../clients/Base64Client");
|
|
17
19
|
class BaseCron {
|
|
18
20
|
constructor() {
|
|
19
21
|
this.isTest = process.env.NODE_ENV === 'test';
|
|
@@ -102,5 +104,22 @@ class BaseCron {
|
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
106
|
}
|
|
107
|
+
get S3Client() {
|
|
108
|
+
if (this.s3Client === undefined) {
|
|
109
|
+
this.s3Client = new AwsS3Client_1.AwsS3Client({
|
|
110
|
+
bucketName: process.env.S3_BUCKET_NAME,
|
|
111
|
+
region: process.env.S3_REGION,
|
|
112
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
113
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return this.s3Client;
|
|
117
|
+
}
|
|
118
|
+
get Base64Client() {
|
|
119
|
+
if (this.base64Client === undefined) {
|
|
120
|
+
this.base64Client = new Base64Client_1.Base64Client();
|
|
121
|
+
}
|
|
122
|
+
return this.base64Client;
|
|
123
|
+
}
|
|
105
124
|
}
|
|
106
125
|
exports.BaseCron = BaseCron;
|
|
@@ -56,7 +56,7 @@ const runCron = (dir, logCallback) => __awaiter(void 0, void 0, void 0, function
|
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
58
|
const filePath = path_1.default.join(dir, file);
|
|
59
|
-
const module = yield Promise.resolve(`${
|
|
59
|
+
const module = yield Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
|
|
60
60
|
const cronClass = module.default;
|
|
61
61
|
const cronInstance = new cronClass();
|
|
62
62
|
cron.schedule(cronInstance.CronSchedule, () => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
package/src/cron/BaseCron.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Pool, PoolClient } from "pg";
|
|
2
2
|
import { DateType, DayType, HourType, MinuteSecondType, MonthType } from "./CronType";
|
|
3
3
|
import PoolManager from "../PoolManager";
|
|
4
|
+
import { AwsS3Client } from "../clients/AwsS3Client";
|
|
5
|
+
import { Base64Client } from "../clients/Base64Client";
|
|
4
6
|
|
|
5
7
|
export class BaseCron {
|
|
6
8
|
|
|
@@ -88,4 +90,25 @@ export class BaseCron {
|
|
|
88
90
|
this.rollback();
|
|
89
91
|
}
|
|
90
92
|
}
|
|
93
|
+
|
|
94
|
+
private s3Client?: AwsS3Client;
|
|
95
|
+
get S3Client(): AwsS3Client {
|
|
96
|
+
if (this.s3Client === undefined) {
|
|
97
|
+
this.s3Client = new AwsS3Client({
|
|
98
|
+
bucketName: process.env.S3_BUCKET_NAME,
|
|
99
|
+
region: process.env.S3_REGION,
|
|
100
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
101
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return this.s3Client;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private base64Client? : Base64Client;
|
|
108
|
+
get Base64Client(): Base64Client {
|
|
109
|
+
if (this.base64Client === undefined) {
|
|
110
|
+
this.base64Client = new Base64Client();
|
|
111
|
+
}
|
|
112
|
+
return this.base64Client;
|
|
113
|
+
}
|
|
91
114
|
}
|
package/src/cron/CronExecuter.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const runCron = async (dir: string, logCallback?: (ex: Error) => Promise<
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const filePath = path.join(dir, file);
|
|
14
|
-
const module = await import(
|
|
14
|
+
const module = await import(filePath);
|
|
15
15
|
const cronClass = module.default;
|
|
16
16
|
const cronInstance: BaseCron = new cronClass();
|
|
17
17
|
|