biz-a-cli 2.3.69 → 2.3.71

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/bin/hubEvent.js CHANGED
@@ -5,6 +5,8 @@ import { createRequire } from "module";
5
5
  const require = createRequire(import.meta.url);
6
6
  const ss = require('socket.io-stream'); //SCY: Temporary, next will be replaced with import
7
7
  import { Transform } from 'node:stream'
8
+ import os from 'node:os';
9
+ const packageJson = require('../package.json');
8
10
  // import { pipeline } from 'node:stream'
9
11
  import { deploymentListenerForHubServer } from './deployEvent.js';
10
12
 
@@ -12,9 +14,9 @@ export const IDLE_SOCKET_TIMEOUT_MILLISECONDS = 1000 * 30;
12
14
  export const RECONNECT_SOCKET_DELAY = 60 * 1000;
13
15
  const DISCONNECT_REASON_BY_SOCKET_SERVER = 'io server disconnect'
14
16
 
15
- export const socketAgent = isUsingHttps=>(isUsingHttps==true) ? tls : net
17
+ export const socketAgent = isUsingHttps => (isUsingHttps == true) ? tls : net
16
18
 
17
- const getIdText = id=>id ? id+' ' : ''
19
+ const getIdText = id => id ? id + ' ' : ''
18
20
 
19
21
  export const streamEvent = async (socket, argv) => new Promise((resolve, reject) => {
20
22
  let id
@@ -36,10 +38,10 @@ export const streamEvent = async (socket, argv) => new Promise((resolve, reject)
36
38
  // console.log(clientId, 'incoming clientId')
37
39
 
38
40
  const addCLIAddressAsResponseHeader = new Transform({
39
- transform(chunk, encoding, next){
41
+ transform(chunk, encoding, next) {
40
42
  const apiResponse = chunk.toString().toLowerCase()
41
43
  const cliAddress = argv.cliAddress()
42
- if ( (apiResponse.indexOf('200 ok') > -1) && (apiResponse.indexOf('server: datasnaphttpservice') > -1)) {
44
+ if ((apiResponse.indexOf('200 ok') > -1) && (apiResponse.indexOf('server: datasnaphttpservice') > -1)) {
43
45
  // don't use string to insert additional headers, chunk can have mixed content of string and binary data
44
46
  const response = Buffer.from(chunk)
45
47
  const delimiter = '\r\n\r\n'
@@ -55,8 +57,8 @@ export const streamEvent = async (socket, argv) => new Promise((resolve, reject)
55
57
  '\r\n'
56
58
  )
57
59
  ])
58
- const body = (response.length>delimiterPos+delimiter.length) ? Buffer.copyBytesFrom(response, delimiterPos+4) : Buffer.from('')
59
- this.push(body.length>0 ? Buffer.concat([header, body]) : header)
60
+ const body = (response.length > delimiterPos + delimiter.length) ? Buffer.copyBytesFrom(response, delimiterPos + 4) : Buffer.from('')
61
+ this.push(body.length > 0 ? Buffer.concat([header, body]) : header)
60
62
  }
61
63
  else {
62
64
  this.push(chunk)
@@ -81,7 +83,7 @@ export const streamEvent = async (socket, argv) => new Promise((resolve, reject)
81
83
  client.destroy()
82
84
  })
83
85
 
84
- socket.once(clientId, ()=>{ // hub server shall notify us to end pipeline as soon as possible
86
+ socket.once(clientId, () => { // hub server shall notify us to end pipeline as soon as possible
85
87
  client.end()
86
88
  })
87
89
 
@@ -113,71 +115,182 @@ export const streamEvent = async (socket, argv) => new Promise((resolve, reject)
113
115
  callback(result.data);
114
116
  }
115
117
 
118
+ const publishReqCb = async (data, callback) => {
119
+ try {
120
+ process.env.BIZA_APP_SKIP_PARSE = '1';
121
+ const { addApp } = await import('./app.js');
122
+
123
+ const requestBody = (typeof data?.body === 'string')
124
+ ? JSON.parse(data.body || '{}')
125
+ : (data?.body || {});
126
+ const hasTransportEnvelope = (
127
+ requestBody &&
128
+ typeof requestBody === 'object' &&
129
+ typeof requestBody.body === 'object' &&
130
+ (
131
+ Object.prototype.hasOwnProperty.call(requestBody, 'method') ||
132
+ Object.prototype.hasOwnProperty.call(requestBody, 'query') ||
133
+ Object.prototype.hasOwnProperty.call(requestBody, 'headers')
134
+ )
135
+ );
136
+ const unwrappedPayload = hasTransportEnvelope ? requestBody.body : requestBody;
137
+ const publishPayload = (unwrappedPayload && typeof unwrappedPayload === 'object' && unwrappedPayload.addApp && typeof unwrappedPayload.addApp === 'object')
138
+ ? unwrappedPayload.addApp
139
+ : unwrappedPayload;
140
+ const params = (publishPayload && typeof publishPayload.options === 'object')
141
+ ? publishPayload.options
142
+ : publishPayload;
143
+ const toNumber = (value, fallback) => {
144
+ const parsed = Number(value);
145
+ return Number.isFinite(parsed) ? parsed : fallback;
146
+ };
147
+
148
+ const response = await addApp({
149
+ workingDir: params.workingDir || process.cwd(),
150
+ verbose: !!params.verbose,
151
+ server: params.server || argv.server || 'http://localhost',
152
+ apiPort: toNumber(params.apiPort, argv.port || 212),
153
+ dbIndex: toNumber(params.dbIndex, argv.dbindex || 2),
154
+ sub: params.sub || params.subdomain || argv.subdomain,
155
+ files: params.files || params.fileList,
156
+ body: publishPayload
157
+ });
158
+
159
+ callback(response);
160
+ } catch (error) {
161
+ callback({
162
+ success: false,
163
+ error: error?.message || error
164
+ });
165
+ } finally {
166
+ delete process.env.BIZA_APP_SKIP_PARSE;
167
+ }
168
+ }
169
+
116
170
  socket.on('connect', connectCb);
117
171
  socket.on('incomingClient', incomingHubCb)
118
172
  socket.on('cli-req', cliReqCb);
173
+ socket.on('publish-req', publishReqCb);
119
174
 
120
- socket.on('disconnect', reason=>{
175
+ socket.on('disconnect', reason => {
121
176
  console.log(`${new Date()}: ${getIdText(id)}disconnected from BizA Server. Reason: ${reason}`)
122
177
  id = undefined
123
- if (reason.toLowerCase()===DISCONNECT_REASON_BY_SOCKET_SERVER) {
178
+ if (reason.toLowerCase() === DISCONNECT_REASON_BY_SOCKET_SERVER) {
124
179
  socket.connect()
125
180
  }
126
181
  })
127
182
 
128
- socket.io.on('reconnect', ()=>{
183
+ socket.io.on('reconnect', () => {
129
184
  console.log(`${new Date()}: ${getIdText(id)}reconnecting to BizA Server`)
130
185
  })
131
186
  return socket
132
187
  })
133
188
 
134
- export const hubEvent = (socket, argv, notifier)=>{
189
+ export const hubEvent = (socket, argv, notifier) => {
135
190
  let id
136
- socket.on('connect', ()=>{
191
+ socket.on('connect', () => {
137
192
  id = socket.id
138
193
  notifier(argv['hubServer'])
139
194
  console.log(`${new Date()}: ${getIdText(id)}connected to BizA Hub at ${argv['hubServer']} using sub domain "${argv['subdomain']}"`)
140
195
  })
141
- socket.on('disconnect', (reason)=>{
196
+ socket.on('disconnect', (reason) => {
142
197
  notifier('')
143
198
  console.log(`${new Date()}: ${getIdText(id)}disconnected from BizA Hub. Reason: ${reason}`)
144
199
  id = undefined
145
- if (reason.toLowerCase()===DISCONNECT_REASON_BY_SOCKET_SERVER) {
200
+ if (reason.toLowerCase() === DISCONNECT_REASON_BY_SOCKET_SERVER) {
146
201
  socket.connect()
147
202
  }
148
203
  })
149
- const logError = msg=>{console.log(`${new Date()}: ${getIdText(id)}connection error to BizA Hub. Error : ${msg}`)}
204
+ const logError = msg=>{console.log(`${new Date()}: ${getIdText(id)}connection error to BizA Hub at ${argv['hubServer']} using sub domain "${argv['subdomain']}". Error : ${msg}`)}
150
205
  socket.on('connect_error', (error)=>{
206
+ // console.log('Connect Error :', error);
151
207
  notifier('')
152
208
  logError(error.message)
153
209
  })
154
- socket.on('error', (error)=>{
210
+ socket.on('error', (error) => {
211
+ // console.log('Error :', error);
155
212
  notifier('')
156
213
  logError(error)
157
214
  })
158
- socket.io.on('reconnect', ()=>{
215
+ socket.io.on('reconnect', () => {
159
216
  notifier('')
160
217
  console.log(`${new Date()}: ${getIdText(id)}reconnecting to BizA Hub`)
161
218
  })
162
- apiRequestListener(socket, argv);
219
+ clientListener(socket, argv);
163
220
  deploymentListenerForHubServer(socket, argv);
164
221
  return socket
165
222
  }
166
223
 
167
- export const apiRequestListener = (socket, argv)=>{
168
- socket.on('apiRequest', (reqData, resCB)=>{
224
+ export const status = (argv)=>{
225
+ const cliAddress = argv.cliAddress();
226
+ const cpuArchitecture = os.arch();
227
+ const osArchitecture = (['x64', 'arm64', 'ppc64', 's390x'].includes(cpuArchitecture)) ? '64-bit' : (['ia32', 'arm', 'mips', 'mipsel', 's390'].includes(cpuArchitecture)) ? '32-bit' : `Unknown CPU architecture: ${cpuArchitecture}`;
228
+ const totalMemory = os.totalmem();
229
+ const freeMemory = os.freemem();
230
+ const usedMemoy = totalMemory - freeMemory;
231
+ const getUptime = ()=>{
232
+ let totalSeconds = Math.floor(process.uptime());
233
+ const days = Math.floor(totalSeconds / (24 * 3600));
234
+ totalSeconds %= (24 * 3600); // Remaining seconds after calculating days
235
+
236
+ const hours = Math.floor(totalSeconds / 3600);
237
+ totalSeconds %= 3600; // Remaining seconds after calculating hours
238
+
239
+ const minutes = Math.floor(totalSeconds / 60);
240
+ const seconds = totalSeconds % 60; // Remaining seconds after calculating minutes
241
+
242
+ return {
243
+ days: days,
244
+ hours: hours,
245
+ minutes: minutes,
246
+ seconds: seconds
247
+ };
248
+ };
249
+
250
+ return {
251
+ cli: {
252
+ address: cliAddress.address,
253
+ publicUrl: cliAddress.publicUrl,
254
+ hubUrl: cliAddress.hubUrl,
255
+ version: packageJson.version,
256
+ mode: process.env.NODE_ENV,
257
+ memoryUsage: `${(process.memoryUsage().rss / (1024 * 1024)).toFixed(2)} MB`,
258
+ nodeVersion: process.version,
259
+ uptime: getUptime()
260
+ },
261
+ api: {
262
+ address: `${argv.hostname}:${argv.port}`,
263
+ dbIndex: argv.dbindex,
264
+ },
265
+ os: {
266
+ name: os.type(),
267
+ architecture: osArchitecture,
268
+ cpuCount: os.cpus().length,
269
+ platform: os.platform(),
270
+ memory: {
271
+ total: (totalMemory / (1024 * 1024 * 1024)).toFixed(2) + ' GB',
272
+ free: (freeMemory / (1024 * 1024 * 1024)).toFixed(2) + ' GB',
273
+ used: (usedMemoy / (1024 * 1024 * 1024)).toFixed(2) + ' GB',
274
+ }
275
+ }
276
+ };
277
+ };
278
+
279
+ export const clientListener = (socket, argv)=>{
280
+ socket
281
+ .on('apiRequest', (reqData, resCB)=>{
169
282
  let apiAddress = `${argv['secure']==true ? 'https://' : 'http://'}${argv['hostname']}:${argv['port']}`
170
283
  let reqBody = reqData.body
171
- try{
172
- let parsedBody = (typeof reqData.body==='object') ? reqBody : JSON.parse(reqBody)
173
- if (parsedBody.apiAddress){
284
+ try {
285
+ let parsedBody = (typeof reqData.body === 'object') ? reqBody : JSON.parse(reqBody)
286
+ if (parsedBody.apiAddress) {
174
287
  apiAddress = parsedBody.apiAddress
175
288
  delete parsedBody.apiAddress
176
- reqBody = (typeof reqData.body==='string') ? JSON.stringify(parsedBody) : parsedBody
289
+ reqBody = (typeof reqData.body === 'string') ? JSON.stringify(parsedBody) : parsedBody
177
290
  }
178
- } catch (error) {}
291
+ } catch (error) { }
179
292
 
180
- const socketResponse = (resp)=>{
293
+ const socketResponse = (resp) => {
181
294
  const cliAddress = argv.cliAddress();
182
295
  let cliAddressHeaders = {};
183
296
  if (cliAddress.publicUrl) {
@@ -189,32 +302,46 @@ export const apiRequestListener = (socket, argv)=>{
189
302
  return {
190
303
  status: resp.status,
191
304
  statusText: resp.statusText,
192
- headers: {...resp.headers, ...cliAddressHeaders},
305
+ headers: { ...resp.headers, ...cliAddressHeaders },
193
306
  body: resp.data,
194
307
  url: apiAddress + resp.config.url
195
308
  };
196
309
  };
197
- if (argv['subdomain'].localeCompare(reqData.subDomain)==0) {
310
+ if (argv['subdomain'].localeCompare(reqData.subDomain) == 0) {
198
311
  axios.request({
199
- timeout : (reqData.timeout || IDLE_SOCKET_TIMEOUT_MILLISECONDS),
200
- baseURL : apiAddress,
201
- url : reqData.path,
202
- method : reqData.method,
203
- headers : reqData.headers,
204
- data : reqBody,
312
+ timeout: (reqData.timeout || IDLE_SOCKET_TIMEOUT_MILLISECONDS),
313
+ baseURL: apiAddress,
314
+ url: reqData.path,
315
+ method: reqData.method,
316
+ headers: reqData.headers,
317
+ data: reqBody,
205
318
  // decompress : false, // if we need to interfered default Agent compression
206
- responseType : reqData.responseType,
207
- maxContentLength : Infinity,
208
- })
209
- .then(response=>{
210
- resCB(null, socketResponse(response))
211
- })
212
- .catch(error=>{
213
- resCB(error, null)
319
+ responseType: reqData.responseType,
320
+ maxContentLength: Infinity,
214
321
  })
322
+ .then(response => {
323
+ resCB(null, socketResponse(response))
324
+ })
325
+ .catch(error => {
326
+ resCB(error, null)
327
+ })
215
328
  }
216
329
  else {
217
- resCB({status: 401, statusText: 'bad subdomain', url: apiAddress + reqData.path}, null)
330
+ resCB({ status: 401, statusText: 'bad subdomain', url: apiAddress + reqData.path }, null)
218
331
  }
219
332
  })
220
- }
333
+ .on('cliCommand', async (data, cb)=>{
334
+ try {
335
+ const command = data.command.trim().toLowerCase();
336
+ switch (command) { //ensure case insensitive
337
+ case 'status':
338
+ cb(null, status(argv));
339
+ break;
340
+ default:
341
+ cb(`Unknown CLI command '${command}'`, null);
342
+ };
343
+ } catch (err) {
344
+ cb(err.message || err, null);
345
+ };
346
+ });
347
+ };
package/bin/log/debug.log CHANGED
@@ -3,3 +3,10 @@
3
3
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
4
4
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
5
5
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:72:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
6
+ {"level":"error","message":"Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'scriptid')","stack":"Error: TypeError: Cannot read properties of undefined (reading 'scriptid')\n at runCliScript (file:///C:/SourceCode/biz-a/cli/callbackController.js:40:15)\n at file:///C:/SourceCode/biz-a/cli/bin/hub.js:137:5\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)\n at C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:286:9\n at router.process_params (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:346:12)\n at next (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:280:10)\n at jsonParser (C:\\SourceCode\\biz-a\\cli\\node_modules\\body-parser\\lib\\types\\json.js:113:7)\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)"}
7
+ {"code":"ERR_INVALID_ARG_TYPE","level":"error","message":"Unhandled Exception: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket","stack":"TypeError [ERR_INVALID_ARG_TYPE]: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\n at eos (node:internal/streams/end-of-stream:86:11)\n at IncomingMessage._destroy (node:_http_incoming:231:21)\n at _destroy (node:internal/streams/destroy:122:10)\n at IncomingMessage.destroy (node:internal/streams/destroy:84:5)\n at abortIncoming (node:_http_server:836:9)\n at socketOnClose (node:_http_server:830:3)\n at Socket.emit (node:events:520:35)\n at TCP.<anonymous> (node:net:346:12)"}
8
+ {"level":"error","message":"Unhandled Exception:"}
9
+ {"level":"error","message":"Unhandled Exception:"}
10
+ {"level":"error","message":"Unhandled Exception:"}
11
+ {"level":"error","message":"Unhandled Exception:"}
12
+ {"level":"error","message":"Unhandled Exception:"}
package/bin/log/error.log CHANGED
@@ -3,3 +3,10 @@
3
3
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
4
4
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
5
5
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:72:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
6
+ {"level":"error","message":"Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'scriptid')","stack":"Error: TypeError: Cannot read properties of undefined (reading 'scriptid')\n at runCliScript (file:///C:/SourceCode/biz-a/cli/callbackController.js:40:15)\n at file:///C:/SourceCode/biz-a/cli/bin/hub.js:137:5\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)\n at C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:286:9\n at router.process_params (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:346:12)\n at next (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:280:10)\n at jsonParser (C:\\SourceCode\\biz-a\\cli\\node_modules\\body-parser\\lib\\types\\json.js:113:7)\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)"}
7
+ {"code":"ERR_INVALID_ARG_TYPE","level":"error","message":"Unhandled Exception: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket","stack":"TypeError [ERR_INVALID_ARG_TYPE]: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\n at eos (node:internal/streams/end-of-stream:86:11)\n at IncomingMessage._destroy (node:_http_incoming:231:21)\n at _destroy (node:internal/streams/destroy:122:10)\n at IncomingMessage.destroy (node:internal/streams/destroy:84:5)\n at abortIncoming (node:_http_server:836:9)\n at socketOnClose (node:_http_server:830:3)\n at Socket.emit (node:events:520:35)\n at TCP.<anonymous> (node:net:346:12)"}
8
+ {"level":"error","message":"Unhandled Exception:"}
9
+ {"level":"error","message":"Unhandled Exception:"}
10
+ {"level":"error","message":"Unhandled Exception:"}
11
+ {"level":"error","message":"Unhandled Exception:"}
12
+ {"level":"error","message":"Unhandled Exception:"}
@@ -0,0 +1,6 @@
1
+ {"date":"Thu Mar 05 2026 17:59:10 GMT+0700 (Indochina Time)","error":{"code":"ERR_INVALID_ARG_TYPE"},"exception":true,"level":"error","message":"uncaughtException: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\nTypeError [ERR_INVALID_ARG_TYPE]: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\n at eos (node:internal/streams/end-of-stream:86:11)\n at IncomingMessage._destroy (node:_http_incoming:231:21)\n at _destroy (node:internal/streams/destroy:122:10)\n at IncomingMessage.destroy (node:internal/streams/destroy:84:5)\n at abortIncoming (node:_http_server:836:9)\n at socketOnClose (node:_http_server:830:3)\n at Socket.emit (node:events:520:35)\n at TCP.<anonymous> (node:net:346:12)","os":{"loadavg":[0,0,0],"uptime":10823.218},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","true"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":42160,"external":3925800,"heapTotal":24539136,"heapUsed":21219944,"rss":76513280},"pid":8104,"uid":null,"version":"v24.9.0"},"stack":"TypeError [ERR_INVALID_ARG_TYPE]: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\n at eos (node:internal/streams/end-of-stream:86:11)\n at IncomingMessage._destroy (node:_http_incoming:231:21)\n at _destroy (node:internal/streams/destroy:122:10)\n at IncomingMessage.destroy (node:internal/streams/destroy:84:5)\n at abortIncoming (node:_http_server:836:9)\n at socketOnClose (node:_http_server:830:3)\n at Socket.emit (node:events:520:35)\n at TCP.<anonymous> (node:net:346:12)","trace":[{"column":11,"file":"node:internal/streams/end-of-stream","function":"eos","line":86,"method":null,"native":false},{"column":21,"file":"node:_http_incoming","function":"IncomingMessage._destroy","line":231,"method":"_destroy","native":false},{"column":10,"file":"node:internal/streams/destroy","function":"_destroy","line":122,"method":null,"native":false},{"column":5,"file":"node:internal/streams/destroy","function":"IncomingMessage.destroy","line":84,"method":"destroy","native":false},{"column":9,"file":"node:_http_server","function":"abortIncoming","line":836,"method":null,"native":false},{"column":3,"file":"node:_http_server","function":"socketOnClose","line":830,"method":null,"native":false},{"column":35,"file":"node:events","function":"Socket.emit","line":520,"method":"emit","native":false},{"column":12,"file":"node:net","function":null,"line":346,"method":null,"native":false}]}
2
+ {"date":"Tue Mar 10 2026 16:32:59 GMT+0700 (Indochina Time)","error":"subdomain already claimed","exception":true,"level":"error","message":"uncaughtException: subdomain already claimed\n No stack trace","os":{"loadavg":[0,0,0],"uptime":21495.281},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","false"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":59701,"external":3958329,"heapTotal":23490560,"heapUsed":21529216,"rss":75493376},"pid":12400,"uid":null,"version":"v24.9.0"},"trace":[]}
3
+ {"date":"Tue Mar 10 2026 16:33:18 GMT+0700 (Indochina Time)","error":"subdomain already claimed","exception":true,"level":"error","message":"uncaughtException: subdomain already claimed\n No stack trace","os":{"loadavg":[0,0,0],"uptime":21514.375},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","false"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":55841,"external":3954469,"heapTotal":38895616,"heapUsed":24237224,"rss":87363584},"pid":1084,"uid":null,"version":"v24.9.0"},"trace":[]}
4
+ {"date":"Tue Mar 10 2026 16:33:38 GMT+0700 (Indochina Time)","error":"subdomain already claimed","exception":true,"level":"error","message":"uncaughtException: subdomain already claimed\n No stack trace","os":{"loadavg":[0,0,0],"uptime":21533.64},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","false"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":51015,"external":3944647,"heapTotal":38633472,"heapUsed":24112424,"rss":85905408},"pid":10868,"uid":null,"version":"v24.9.0"},"trace":[]}
5
+ {"date":"Thu Mar 12 2026 11:26:48 GMT+0700 (Indochina Time)","error":"subdomain already claimed","exception":true,"level":"error","message":"uncaughtException: subdomain already claimed\n No stack trace","os":{"loadavg":[0,0,0],"uptime":7485.546},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","false","--hub"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":64622,"external":3965748,"heapTotal":23228416,"heapUsed":22045744,"rss":78213120},"pid":3108,"uid":null,"version":"v24.9.0"},"trace":[]}
6
+ {"date":"Thu Mar 12 2026 11:26:59 GMT+0700 (Indochina Time)","error":"subdomain already claimed","exception":true,"level":"error","message":"uncaughtException: subdomain already claimed\n No stack trace","os":{"loadavg":[0,0,0],"uptime":7496.515},"process":{"argv":["C:\\nvm4w\\nodejs\\node.exe","C:\\SourceCode\\biz-a\\cli\\bin\\hub","--server","https://devserver.biz-a.id","--sub","scydev","--hostname","localhost","--port","212","--publish","false"],"cwd":"C:\\SourceCode\\biz-a\\cli\\bin","execPath":"C:\\nvm4w\\nodejs\\node.exe","gid":null,"memoryUsage":{"arrayBuffers":46355,"external":3942485,"heapTotal":38895616,"heapUsed":24416256,"rss":86667264},"pid":1948,"uid":null,"version":"v24.9.0"},"trace":[]}
package/bin/log/info.log CHANGED
@@ -3,3 +3,10 @@
3
3
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
4
4
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:70:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
5
5
  {"level":"error","message":"Unhandled Rejection: Invalid time zone specified: null","stack":"RangeError: Invalid time zone specified: null\n at Date.toLocaleString (<anonymous>)\n at f.tz (c:\\SourceCode\\biz-a\\cli\\node_modules\\dayjs\\plugin\\timezone.js:1:1041)\n at setTimeZoneDate (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:79:23)\n at isItTime (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:84:26)\n at file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:93:33\n at Array.map (<anonymous>)\n at loopTimer (file:///c:/SourceCode/biz-a/cli/scheduler/watcherlib.js:92:27)\n at Module.runScheduler (file:///c:/SourceCode/biz-a/cli/scheduler/timer.js:72:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}
6
+ {"level":"error","message":"Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'scriptid')","stack":"Error: TypeError: Cannot read properties of undefined (reading 'scriptid')\n at runCliScript (file:///C:/SourceCode/biz-a/cli/callbackController.js:40:15)\n at file:///C:/SourceCode/biz-a/cli/bin/hub.js:137:5\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)\n at C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:286:9\n at router.process_params (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:346:12)\n at next (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:280:10)\n at jsonParser (C:\\SourceCode\\biz-a\\cli\\node_modules\\body-parser\\lib\\types\\json.js:113:7)\n at Layer.handle [as handle_request] (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\layer.js:95:5)\n at trim_prefix (C:\\SourceCode\\biz-a\\cli\\node_modules\\express\\lib\\router\\index.js:328:13)"}
7
+ {"code":"ERR_INVALID_ARG_TYPE","level":"error","message":"Unhandled Exception: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket","stack":"TypeError [ERR_INVALID_ARG_TYPE]: The \"stream\" argument must be an instance of ReadableStream, WritableStream, or Stream. Received an instance of Socket\n at eos (node:internal/streams/end-of-stream:86:11)\n at IncomingMessage._destroy (node:_http_incoming:231:21)\n at _destroy (node:internal/streams/destroy:122:10)\n at IncomingMessage.destroy (node:internal/streams/destroy:84:5)\n at abortIncoming (node:_http_server:836:9)\n at socketOnClose (node:_http_server:830:3)\n at Socket.emit (node:events:520:35)\n at TCP.<anonymous> (node:net:346:12)"}
8
+ {"level":"error","message":"Unhandled Exception:"}
9
+ {"level":"error","message":"Unhandled Exception:"}
10
+ {"level":"error","message":"Unhandled Exception:"}
11
+ {"level":"error","message":"Unhandled Exception:"}
12
+ {"level":"error","message":"Unhandled Exception:"}
package/envs/env.dev.js CHANGED
@@ -5,6 +5,6 @@ export const envDev = {
5
5
  CDM_MONGO_LINK: 'mongodb+srv://imm_cdm:' +
6
6
  encodeURIComponent('imm@2019') + '@imm-cdm-dev.rf6wr.mongodb.net/?retryWrites=true&w=majority',
7
7
  COMPANY_REGISTER: 'companyregister-dev',
8
- BIZA_SERVER_LINK: 'https://devserver.biz-a.id',
9
- BIZA_HUB_SERVER_LINK: 'https://hub.biz-a.id'
8
+ BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com',
9
+ BIZA_HUB_SERVER_LINK: 'https://hub.biz-a.id' // https://biz-a-hub-ed77b066db87.herokuapp.com/
10
10
  };
package/envs/env.js CHANGED
@@ -7,4 +7,5 @@ export const env = {
7
7
  COMPANY_REGISTER: 'companyregister',
8
8
  BIZA_SERVER_LINK: 'https://server.biz-a.id',
9
9
  BIZA_HUB_SERVER_LINK: 'https://hub.biz-a.id'
10
+ // BIZA_HUB_SERVER_LINK: 'https://biz-a-hub-ed77b066db87.herokuapp.com'
10
11
  };
package/package.json CHANGED
@@ -1,73 +1,71 @@
1
1
  {
2
- "name": "biz-a-cli",
3
- "nameDev": "biz-a-cli-dev",
4
- "version": "2.3.69",
5
- "versionDev": "0.0.34",
6
- "description": "",
7
- "main": "bin/index.js",
8
- "type": "module",
9
- "engines": {
10
- "node": ">=20.16.0",
11
- "npm": ">=10.8.1"
12
- },
13
- "scripts": {
14
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch a",
15
- "testOnce": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
16
- "dev": "node --watch server.js",
17
- "hub": "set NODE_ENV=dev&& node --experimental-vm-modules bin/hub.js"
18
- },
19
- "author": "Imamatek",
20
- "license": "ISC",
21
- "bin": {
22
- "uploadbiza": "bin/index.js",
23
- "proxy": "bin/proxy.js",
24
- "hub": "bin/hub.js",
25
- "watcher": "bin/watcher.js",
26
- "uploadapp": "bin/uploadApp.js",
27
- "deleteapp": "bin/deleteApp.js",
28
- "biza": "bin/app.js"
29
- },
30
- "dependencies": {
31
- "axios": "^1.7.8",
32
- "cloudflared": "^0.6.0",
33
- "compression": "^1.7.5",
34
- "cors": "^2.8.5",
35
- "dayjs": "^1.11.10",
36
- "express": "^4.18.3",
37
- "mongodb": "^6.5.0",
38
- "net": "^1.0.2",
39
- "nodemailer": "^6.9.12",
40
- "socket.io": "^4.7.5",
41
- "socket.io-client": "^4.7.5",
42
- "socket.io-stream": "^0.9.1",
43
- "tar": "^7.4.0",
44
- "uglify-js": "^3.19.3",
45
- "web-push": "^3.6.7",
46
- "winston": "^3.13.0",
47
- "yargs": "^17.7.2"
48
- },
49
- "devDependencies": {
50
- "jest": "^29.7.0"
51
- },
52
- "jest": {
53
- "transform": {},
54
- "testMatch": [
55
- "<rootDir>/tests/**",
56
- "!<rootDir>/tests/mockData",
57
- "!<rootDir>/tests/mockData/**"
58
- ],
59
- "testPathIgnorePatterns": [
60
- "<rootDir>/node_modules",
61
- "<rootDir>/tests/mockData"
62
- ],
63
- "watchPathIgnorePatterns": [
64
- "<rootDir>/node_modules",
65
- "<rootDir>/tests/mockData"
66
- ],
67
- "coveragePathIgnorePatterns": [
68
- "<rootDir>/node_modules",
69
- "<rootDir>/tests/mockData",
70
- "<rootDir>/tests/mockData/**"
71
- ]
72
- }
73
- }
2
+ "name": "biz-a-cli",
3
+ "version": "2.3.71",
4
+ "description": "",
5
+ "main": "bin/index.js",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20.16.0",
9
+ "npm": ">=10.8.1"
10
+ },
11
+ "scripts": {
12
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch a",
13
+ "testOnce": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
14
+ "dev": "node --watch server.js",
15
+ "hub": "set NODE_ENV=dev&& node --experimental-vm-modules bin/hub.js"
16
+ },
17
+ "author": "Imamatek",
18
+ "license": "ISC",
19
+ "bin": {
20
+ "uploadbiza": "bin/index.js",
21
+ "proxy": "bin/proxy.js",
22
+ "hub": "bin/hub.js",
23
+ "watcher": "bin/watcher.js",
24
+ "uploadapp": "bin/uploadApp.js",
25
+ "deleteapp": "bin/deleteApp.js",
26
+ "biza": "bin/app.js"
27
+ },
28
+ "dependencies": {
29
+ "axios": "^1.7.8",
30
+ "cloudflared": "^0.6.0",
31
+ "compression": "^1.7.5",
32
+ "cors": "^2.8.5",
33
+ "dayjs": "^1.11.10",
34
+ "express": "^4.18.3",
35
+ "mongodb": "^6.5.0",
36
+ "net": "^1.0.2",
37
+ "nodemailer": "^6.9.12",
38
+ "socket.io": "^4.7.5",
39
+ "socket.io-client": "^4.7.5",
40
+ "socket.io-stream": "^0.9.1",
41
+ "tar": "^7.4.0",
42
+ "uglify-js": "^3.19.3",
43
+ "web-push": "^3.6.7",
44
+ "winston": "^3.13.0",
45
+ "yargs": "^17.7.2"
46
+ },
47
+ "devDependencies": {
48
+ "jest": "^29.7.0"
49
+ },
50
+ "jest": {
51
+ "transform": {},
52
+ "testMatch": [
53
+ "<rootDir>/tests/**",
54
+ "!<rootDir>/tests/mockData",
55
+ "!<rootDir>/tests/mockData/**"
56
+ ],
57
+ "testPathIgnorePatterns": [
58
+ "<rootDir>/node_modules",
59
+ "<rootDir>/tests/mockData"
60
+ ],
61
+ "watchPathIgnorePatterns": [
62
+ "<rootDir>/node_modules",
63
+ "<rootDir>/tests/mockData"
64
+ ],
65
+ "coveragePathIgnorePatterns": [
66
+ "<rootDir>/node_modules",
67
+ "<rootDir>/tests/mockData",
68
+ "<rootDir>/tests/mockData/**"
69
+ ]
70
+ }
71
+ }