@quatrain/worker 1.1.18 → 1.1.20
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/lib/FileSystem.js +3 -28
- package/lib/Worker.js +8 -6
- package/package.json +2 -2
package/lib/FileSystem.js
CHANGED
|
@@ -35,7 +35,7 @@ const node_fetch_native_1 = __importDefault(require("node-fetch-native"));
|
|
|
35
35
|
const ffmpeg = __importStar(require("fluent-ffmpeg"));
|
|
36
36
|
class FileSystem {
|
|
37
37
|
static prepare(folder) {
|
|
38
|
-
Worker_1.Worker.
|
|
38
|
+
Worker_1.Worker.debug(`Setting up process folder ${folder}`);
|
|
39
39
|
this.removeFolder(folder);
|
|
40
40
|
node_fs_1.default.mkdirSync(folder);
|
|
41
41
|
node_fs_1.default.mkdirSync(folder + node_path_1.default.sep + 'images');
|
|
@@ -81,31 +81,6 @@ class FileSystem {
|
|
|
81
81
|
static safeString(name) {
|
|
82
82
|
return name.replace(/\s+/g, '_');
|
|
83
83
|
}
|
|
84
|
-
// static uploadFile18(
|
|
85
|
-
// filename: string,
|
|
86
|
-
// destination: string,
|
|
87
|
-
// mime: string = 'application/octet-stream'
|
|
88
|
-
// ) {
|
|
89
|
-
// return new Promise((resolve, reject) => {
|
|
90
|
-
// try {
|
|
91
|
-
// const { size } = fs.statSync(filename)
|
|
92
|
-
// const bufferContent = fs.readFileSync(filename)
|
|
93
|
-
// fetch(destination, {
|
|
94
|
-
// method: 'POST',
|
|
95
|
-
// mode: 'cors',
|
|
96
|
-
// headers: {
|
|
97
|
-
// 'Content-Type': mime,
|
|
98
|
-
// 'Content-length': String(size),
|
|
99
|
-
// },
|
|
100
|
-
// body: bufferContent,
|
|
101
|
-
// })
|
|
102
|
-
// .then(() => resolve(undefined))
|
|
103
|
-
// .catch((err) => reject(err))
|
|
104
|
-
// } catch (err: any) {
|
|
105
|
-
// reject(err as Error)
|
|
106
|
-
// }
|
|
107
|
-
// })
|
|
108
|
-
// }
|
|
109
84
|
/**
|
|
110
85
|
* Upload file to public URL and return meta data
|
|
111
86
|
* @param filename string
|
|
@@ -143,11 +118,11 @@ class FileSystem {
|
|
|
143
118
|
'Content-length': String(size),
|
|
144
119
|
},
|
|
145
120
|
})
|
|
146
|
-
.then((
|
|
121
|
+
.then(() => resolve({ ...meta, size, uploadUrl: undefined }))
|
|
147
122
|
.catch((err) => reject(err));
|
|
148
123
|
}
|
|
149
124
|
catch (err) {
|
|
150
|
-
|
|
125
|
+
Worker_1.Worker.error(err);
|
|
151
126
|
reject(err);
|
|
152
127
|
}
|
|
153
128
|
});
|
package/lib/Worker.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Worker = void 0;
|
|
|
7
7
|
const core_1 = require("@quatrain/core");
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const https_1 = __importDefault(require("https"));
|
|
10
11
|
const child_process_1 = require("child_process");
|
|
11
12
|
class Worker extends core_1.Core {
|
|
12
13
|
static endpoint = '';
|
|
@@ -24,12 +25,8 @@ class Worker extends core_1.Core {
|
|
|
24
25
|
args.forEach((arg) => console.log(`\t${arg}`));
|
|
25
26
|
return new Promise((resolve, reject) => {
|
|
26
27
|
const child = (0, child_process_1.spawn)(command, args, { cwd });
|
|
27
|
-
child.stdout.on('data', (data) =>
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
child.stderr.on('data', (data) => {
|
|
31
|
-
Worker.debug(data.toString());
|
|
32
|
-
});
|
|
28
|
+
child.stdout.on('data', (data) => Worker.debug(data.toString()));
|
|
29
|
+
child.stderr.on('data', (data) => Worker.debug(data.toString()));
|
|
33
30
|
child.on('close', (code) => {
|
|
34
31
|
if (code !== 0) {
|
|
35
32
|
Worker.error(`Command execution failed with code: ${code}`);
|
|
@@ -62,6 +59,11 @@ class Worker extends core_1.Core {
|
|
|
62
59
|
...data,
|
|
63
60
|
ts,
|
|
64
61
|
};
|
|
62
|
+
axios_1.default.create({
|
|
63
|
+
httpsAgent: new https_1.default.Agent({
|
|
64
|
+
rejectUnauthorized: false,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
65
67
|
axios_1.default
|
|
66
68
|
.patch(Worker.endpoint, payload)
|
|
67
69
|
.then((res) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/worker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "Container Worker helpers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"typescript": "^5.1.5"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quatrain/core": "^1.1.
|
|
28
|
+
"@quatrain/core": "^1.1.18",
|
|
29
29
|
"axios": "^1.7.7",
|
|
30
30
|
"fluent-ffmpeg": "^2.1.2",
|
|
31
31
|
"fs-extra": "^11.2.0",
|