w-converhp 2.0.48 → 2.0.50

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.
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="tag-source">Source:</dt>
82
82
  <dd class="tag-source"><ul class="dummy"><li>
83
- <a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line95">line 95</a>
83
+ <a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line96">line 96</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -402,6 +402,46 @@
402
402
 
403
403
 
404
404
 
405
+ <tr>
406
+
407
+ <td class="name"><code>timeout</code></td>
408
+
409
+
410
+ <td class="type">
411
+
412
+
413
+ <span class="param-type">Integer</span>
414
+
415
+
416
+
417
+
418
+ </td>
419
+
420
+
421
+ <td class="attributes">
422
+
423
+ &lt;optional><br>
424
+
425
+
426
+
427
+
428
+
429
+ </td>
430
+
431
+
432
+
433
+ <td class="default">
434
+
435
+ <code>5*60*1000</code>
436
+
437
+ </td>
438
+
439
+
440
+ <td class="description last"><p>輸入最長等待時間整數,單位ms,預設為5<em>60</em>1000、為5分鐘</p></td>
441
+ </tr>
442
+
443
+
444
+
405
445
  <tr>
406
446
 
407
447
  <td class="name"><code>retry</code></td>
@@ -432,12 +472,12 @@
432
472
 
433
473
  <td class="default">
434
474
 
435
- <code>3</code>
475
+ <code>10</code>
436
476
 
437
477
  </td>
438
478
 
439
479
 
440
- <td class="description last"><p>輸入傳輸失敗重試次數整數,預設為3</p></td>
480
+ <td class="description last"><p>輸入傳輸失敗重試次數整數,預設為10</p></td>
441
481
  </tr>
442
482
 
443
483
 
@@ -529,7 +569,7 @@
529
569
  <br class="clear">
530
570
 
531
571
  <footer>
532
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
572
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:09:34 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
533
573
  </footer>
534
574
 
535
575
  <script>prettyPrint();</script>
@@ -80,7 +80,8 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
80
80
  * @param {Function} [opt.getToken=()=>''] 輸入取得使用者token的回調函數,預設()=>''
81
81
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
82
82
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
83
- * @param {Integer} [opt.retry=3] 輸入傳輸失敗重試次數整數,預設為3
83
+ * @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
84
+ * @param {Integer} [opt.retry=10] 輸入傳輸失敗重試次數整數,預設為10
84
85
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
85
86
  * @example
86
87
  *
@@ -182,6 +183,12 @@ function WConverhpClient(opt) {
182
183
  sizeSlice = 1024 * 1024 //1m
183
184
  }
184
185
 
186
+ //timeout
187
+ let timeout = get(opt, 'timeout')
188
+ if (!isp0int(timeout)) {
189
+ timeout = 5 * 60 * 1000 //5min
190
+ }
191
+
185
192
  //retry
186
193
  let retry = get(opt, 'retry')
187
194
  if (!isp0int(retry)) {
@@ -487,7 +494,7 @@ function WConverhpClient(opt) {
487
494
  ...ct,
488
495
  ...headers,
489
496
  },
490
- timeout: 60 * 60 * 1000, //1hr
497
+ timeout,
491
498
  maxContentLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
492
499
  maxBodyLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
493
500
  responseType: rt,
@@ -800,7 +807,7 @@ function WConverhpClient(opt) {
800
807
  }
801
808
 
802
809
  //針對伺服器上已有切片檔案計算hash與比對
803
- if (resUpCkt.slks.length > 0) {
810
+ if (resUpCkt.bSls > 0) {
804
811
  // console.log('receive slks...', resUpCkt.slks[0], size(resUpCkt.slks))
805
812
 
806
813
  //fileSliceHashs
@@ -1134,7 +1141,7 @@ export default WConverhpClient
1134
1141
  <br class="clear">
1135
1142
 
1136
1143
  <footer>
1137
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1144
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:09:34 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1138
1145
  </footer>
1139
1146
 
1140
1147
  <script>prettyPrint();</script>
@@ -344,7 +344,7 @@
344
344
 
345
345
  <tr>
346
346
 
347
- <td class="name"><code>apiName</code></td>
347
+ <td class="name"><code>pathUploadTemp</code></td>
348
348
 
349
349
 
350
350
  <td class="type">
@@ -372,19 +372,19 @@
372
372
 
373
373
  <td class="default">
374
374
 
375
- <code>'api'</code>
375
+ <code>'./uploadTemp'</code>
376
376
 
377
377
  </td>
378
378
 
379
379
 
380
- <td class="description last"><p>輸入API名稱字串,預設'api'</p></td>
380
+ <td class="description last"><p>輸入暫時存放切片上傳檔案資料夾字串,預設'./uploadTemp'</p></td>
381
381
  </tr>
382
382
 
383
383
 
384
384
 
385
385
  <tr>
386
386
 
387
- <td class="name"><code>pathUploadTemp</code></td>
387
+ <td class="name"><code>apiName</code></td>
388
388
 
389
389
 
390
390
  <td class="type">
@@ -412,12 +412,12 @@
412
412
 
413
413
  <td class="default">
414
414
 
415
- <code>'./uploadTemp'</code>
415
+ <code>'api'</code>
416
416
 
417
417
  </td>
418
418
 
419
419
 
420
- <td class="description last"><p>輸入暫時存放切片上傳檔案資料夾字串,預設'./uploadTemp'</p></td>
420
+ <td class="description last"><p>輸入API名稱字串,預設'api'</p></td>
421
421
  </tr>
422
422
 
423
423
 
@@ -749,7 +749,7 @@
749
749
  <br class="clear">
750
750
 
751
751
  <footer>
752
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
752
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:09:34 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
753
753
  </footer>
754
754
 
755
755
  <script>prettyPrint();</script>
@@ -90,8 +90,8 @@ import checkSlicesHash from './checkSlicesHash.wk.umd.js'
90
90
  * @param {Integer} [opt.port=8080] 輸入Hapi伺服器所在port正整數,預設8080
91
91
  * @param {Boolean} [opt.useInert=true] 輸入是否提供瀏覽pathStaticFiles資料夾內檔案之布林值,預設true
92
92
  * @param {String} [opt.pathStaticFiles='dist'] 輸入當useInert=true時提供瀏覽資料夾字串,預設'dist'
93
- * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
94
93
  * @param {String} [opt.pathUploadTemp='./uploadTemp'] 輸入暫時存放切片上傳檔案資料夾字串,預設'./uploadTemp'
94
+ * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
95
95
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
96
96
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
97
97
  * @param {Function} [opt.verifyConn=()=>{return true}] 輸入呼叫API時檢測函數,預設()=>{return true}
@@ -256,12 +256,6 @@ function WConverhpServer(opt = {}) {
256
256
  pathStaticFiles = 'dist'
257
257
  }
258
258
 
259
- //apiName
260
- let apiName = get(opt, 'apiName')
261
- if (!isestr(apiName)) {
262
- apiName = 'api'
263
- }
264
-
265
259
  //pathUploadTemp
266
260
  let pathUploadTemp = get(opt, 'pathUploadTemp')
267
261
  if (!isestr(pathUploadTemp)) {
@@ -271,6 +265,12 @@ function WConverhpServer(opt = {}) {
271
265
  fsCreateFolder(pathUploadTemp)
272
266
  }
273
267
 
268
+ //apiName
269
+ let apiName = get(opt, 'apiName')
270
+ if (!isestr(apiName)) {
271
+ apiName = 'api'
272
+ }
273
+
274
274
  //tokenType
275
275
  let tokenType = get(opt, 'tokenType')
276
276
  if (!isestr(tokenType)) {
@@ -604,9 +604,9 @@ function WConverhpServer(opt = {}) {
604
604
 
605
605
  //error
606
606
  req.payload.on('error', (err) => {
607
- // console.log(`req.payload error`, err)
608
- eeEmit('error', `receive payload err`)
609
- pm.reject(err.message)
607
+ console.log(`apiMain req.payload err`, err) //使用err.message會過於簡化, 另外要開啟顯示err供debug
608
+ eeEmit('error', `receive payload error: ${err.message}`)
609
+ pm.reject(`receive payload error: ${err.message}`)
610
610
  })
611
611
 
612
612
  return pm
@@ -969,16 +969,16 @@ function WConverhpServer(opt = {}) {
969
969
 
970
970
  //setTimeout, 切片上傳添加延遲處理, 避免佔滿伺服器CPU與流量
971
971
  setTimeout(() => {
972
- pm.resolve(`chunk[${chunkIndex}/${chunkTotal}] of packageId[${packageId}] done`)
972
+ pm.resolve(`chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] done`)
973
973
  }, delayForSlice)
974
974
 
975
975
  })
976
976
 
977
977
  //error
978
978
  req.payload.on('error', (err) => {
979
- // console.log(`receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] err`, err)
980
- eeEmit('error', `receive chunk[${chunkIndex}/${chunkTotal}] of packageId[${packageId}] err`)
981
- pm.reject(`apiUploadSlice receive error: ${err.message}`)
979
+ console.log(`apiUploadSlice req.payload chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] err`, err) //使用err.message會過於簡化, 另外要開啟顯示err供debug
980
+ eeEmit('error', `receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] error: ${err.message}`)
981
+ pm.reject(`receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] error: ${err.message}`)
982
982
  })
983
983
 
984
984
  return pm
@@ -1485,7 +1485,7 @@ export default WConverhpServer
1485
1485
  <br class="clear">
1486
1486
 
1487
1487
  <footer>
1488
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1488
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:09:34 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1489
1489
  </footer>
1490
1490
 
1491
1491
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sat May 17 2025 20:54:14 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:09:34 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-converhp",
3
- "version": "2.0.48",
3
+ "version": "2.0.50",
4
4
  "main": "dist/w-converhp-server.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.0",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "form-data": "^4.0.2",
14
- "w-package-tools": "^1.0.90"
14
+ "w-package-tools": "^1.1.0"
15
15
  },
16
16
  "scripts": {
17
17
  "@hapi/hapi": "^20.2.1",
@@ -33,7 +33,8 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
33
33
  * @param {Function} [opt.getToken=()=>''] 輸入取得使用者token的回調函數,預設()=>''
34
34
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
35
35
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
36
- * @param {Integer} [opt.retry=3] 輸入傳輸失敗重試次數整數,預設為3
36
+ * @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
37
+ * @param {Integer} [opt.retry=10] 輸入傳輸失敗重試次數整數,預設為10
37
38
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
38
39
  * @example
39
40
  *
@@ -135,6 +136,12 @@ function WConverhpClient(opt) {
135
136
  sizeSlice = 1024 * 1024 //1m
136
137
  }
137
138
 
139
+ //timeout
140
+ let timeout = get(opt, 'timeout')
141
+ if (!isp0int(timeout)) {
142
+ timeout = 5 * 60 * 1000 //5min
143
+ }
144
+
138
145
  //retry
139
146
  let retry = get(opt, 'retry')
140
147
  if (!isp0int(retry)) {
@@ -440,7 +447,7 @@ function WConverhpClient(opt) {
440
447
  ...ct,
441
448
  ...headers,
442
449
  },
443
- timeout: 60 * 60 * 1000, //1hr
450
+ timeout,
444
451
  maxContentLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
445
452
  maxBodyLength: Infinity, //1024 * 1024 * 1024, Infinity //axios於nodejs中會限制內容大小故需改為無限
446
453
  responseType: rt,
@@ -753,7 +760,7 @@ function WConverhpClient(opt) {
753
760
  }
754
761
 
755
762
  //針對伺服器上已有切片檔案計算hash與比對
756
- if (resUpCkt.slks.length > 0) {
763
+ if (resUpCkt.bSls > 0) {
757
764
  // console.log('receive slks...', resUpCkt.slks[0], size(resUpCkt.slks))
758
765
 
759
766
  //fileSliceHashs
@@ -43,8 +43,8 @@ import checkSlicesHash from './checkSlicesHash.wk.umd.js'
43
43
  * @param {Integer} [opt.port=8080] 輸入Hapi伺服器所在port正整數,預設8080
44
44
  * @param {Boolean} [opt.useInert=true] 輸入是否提供瀏覽pathStaticFiles資料夾內檔案之布林值,預設true
45
45
  * @param {String} [opt.pathStaticFiles='dist'] 輸入當useInert=true時提供瀏覽資料夾字串,預設'dist'
46
- * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
47
46
  * @param {String} [opt.pathUploadTemp='./uploadTemp'] 輸入暫時存放切片上傳檔案資料夾字串,預設'./uploadTemp'
47
+ * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
48
48
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
49
49
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
50
50
  * @param {Function} [opt.verifyConn=()=>{return true}] 輸入呼叫API時檢測函數,預設()=>{return true}
@@ -209,12 +209,6 @@ function WConverhpServer(opt = {}) {
209
209
  pathStaticFiles = 'dist'
210
210
  }
211
211
 
212
- //apiName
213
- let apiName = get(opt, 'apiName')
214
- if (!isestr(apiName)) {
215
- apiName = 'api'
216
- }
217
-
218
212
  //pathUploadTemp
219
213
  let pathUploadTemp = get(opt, 'pathUploadTemp')
220
214
  if (!isestr(pathUploadTemp)) {
@@ -224,6 +218,12 @@ function WConverhpServer(opt = {}) {
224
218
  fsCreateFolder(pathUploadTemp)
225
219
  }
226
220
 
221
+ //apiName
222
+ let apiName = get(opt, 'apiName')
223
+ if (!isestr(apiName)) {
224
+ apiName = 'api'
225
+ }
226
+
227
227
  //tokenType
228
228
  let tokenType = get(opt, 'tokenType')
229
229
  if (!isestr(tokenType)) {
@@ -557,9 +557,9 @@ function WConverhpServer(opt = {}) {
557
557
 
558
558
  //error
559
559
  req.payload.on('error', (err) => {
560
- // console.log(`req.payload error`, err)
561
- eeEmit('error', `receive payload err`)
562
- pm.reject(err.message)
560
+ console.log(`apiMain req.payload err`, err) //使用err.message會過於簡化, 另外要開啟顯示err供debug
561
+ eeEmit('error', `receive payload error: ${err.message}`)
562
+ pm.reject(`receive payload error: ${err.message}`)
563
563
  })
564
564
 
565
565
  return pm
@@ -922,16 +922,16 @@ function WConverhpServer(opt = {}) {
922
922
 
923
923
  //setTimeout, 切片上傳添加延遲處理, 避免佔滿伺服器CPU與流量
924
924
  setTimeout(() => {
925
- pm.resolve(`chunk[${chunkIndex}/${chunkTotal}] of packageId[${packageId}] done`)
925
+ pm.resolve(`chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] done`)
926
926
  }, delayForSlice)
927
927
 
928
928
  })
929
929
 
930
930
  //error
931
931
  req.payload.on('error', (err) => {
932
- // console.log(`receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] err`, err)
933
- eeEmit('error', `receive chunk[${chunkIndex}/${chunkTotal}] of packageId[${packageId}] err`)
934
- pm.reject(`apiUploadSlice receive error: ${err.message}`)
932
+ console.log(`apiUploadSlice req.payload chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] err`, err) //使用err.message會過於簡化, 另外要開啟顯示err供debug
933
+ eeEmit('error', `receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] error: ${err.message}`)
934
+ pm.reject(`receive chunk[${chunkIndex + 1}/${chunkTotal}] of packageId[${packageId}] error: ${err.message}`)
935
935
  })
936
936
 
937
937
  return pm