@quatrain/worker 1.1.17 → 1.1.19

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 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.log(`Setting up process folder ${folder}`);
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((res) => resolve({ ...meta, size, uploadUrl: undefined }))
121
+ .then(() => resolve({ ...meta, size, uploadUrl: undefined }))
147
122
  .catch((err) => reject(err));
148
123
  }
149
124
  catch (err) {
150
- console.log(err);
125
+ Worker_1.Worker.error(err);
151
126
  reject(err);
152
127
  }
153
128
  });
@@ -169,7 +144,7 @@ class FileSystem {
169
144
  resolve({
170
145
  width,
171
146
  height,
172
- framerate: framerate.toFixed(0),
147
+ framerate: parseInt(framerate.toFixed(0)),
173
148
  duration: parseInt(duration),
174
149
  bitrate,
175
150
  });
package/lib/Worker.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Core } from '@quatrain/core';
2
2
  export declare class Worker extends Core {
3
3
  static endpoint: string;
4
4
  static logger: any;
5
+ constructor();
5
6
  /**
6
7
  * Execute an external command in a promise
7
8
  * @see https://stackoverflow.com/questions/46289682/how-to-wait-for-child-process-spawn-execution-with-async-await
package/lib/Worker.js CHANGED
@@ -7,10 +7,19 @@ 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 = '';
13
14
  static logger = this.addLogger('Worker');
15
+ constructor() {
16
+ super();
17
+ axios_1.default.create({
18
+ httpsAgent: new https_1.default.Agent({
19
+ rejectUnauthorized: false,
20
+ }),
21
+ });
22
+ }
14
23
  /**
15
24
  * Execute an external command in a promise
16
25
  * @see https://stackoverflow.com/questions/46289682/how-to-wait-for-child-process-spawn-execution-with-async-await
@@ -20,16 +29,12 @@ class Worker extends core_1.Core {
20
29
  * @return Promise
21
30
  */
22
31
  static execPromise = (command, args = [], cwd = process.cwd()) => {
23
- Worker.log(`Executing command ${command} in ${cwd} with arguments:`);
32
+ Worker.info(`Executing command ${command} in ${cwd} with arguments:`);
24
33
  args.forEach((arg) => console.log(`\t${arg}`));
25
34
  return new Promise((resolve, reject) => {
26
35
  const child = (0, child_process_1.spawn)(command, args, { cwd });
27
- child.stdout.on('data', (data) => {
28
- Worker.debug(data.toString());
29
- });
30
- child.stderr.on('data', (data) => {
31
- Worker.debug(data.toString());
32
- });
36
+ child.stdout.on('data', (data) => Worker.debug(data.toString()));
37
+ child.stderr.on('data', (data) => Worker.debug(data.toString()));
33
38
  child.on('close', (code) => {
34
39
  if (code !== 0) {
35
40
  Worker.error(`Command execution failed with code: ${code}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/worker",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
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.15",
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",