w-converhp 2.0.2 → 2.0.4

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#line133">line 133</a>
83
+ <a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line134">line 134</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -127,7 +127,7 @@
127
127
 
128
128
  <h5 class="h5-examples">Example</h5>
129
129
 
130
- <pre class="prettyprint"><code>import WConverhpClient from 'w-converhp/dist/w-converhp-client.umd.js'
131
130
  FormData,
132
131
  url: 'http://localhost:8080',
133
132
  apiName: 'api',
134
133
  //p
135
134
  let p = {
136
135
  a: 12,
137
136
  b: 34.56,
138
137
  c: 'test中文',
139
138
  d: {
140
139
  name,
141
140
  u8a,
142
141
  },
143
142
  }
144
143
  console.log('p', p)
145
144
  //execute
146
145
  await wo.execute('add', { p },
147
146
  function (prog, p, m) {
148
147
  console.log('client web: execute: prog', prog, p, m)
149
148
  })
150
149
  .then(function(r) {
151
150
  console.log('client web: execute: add', r)
152
151
  console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
153
152
  // w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
154
153
  })
155
154
  .catch(function (err) {
156
155
  console.log('client web: execute: catch', err)
157
156
  })
158
157
  let core = async() => {
159
158
  //u8a
160
159
  let u8a = new Uint8Array([66, 97, 115])
161
160
  console.log('executeWithU8a u8a', u8a)
162
161
  //execute
163
162
  await execute('zdata.b1', u8a)
164
163
  }
165
164
  core()
166
165
  let core = async() => {
167
166
  //u8a
168
167
  let u8a = new Uint8Array(fs.readFileSync('../_data/10mb.7z'))
169
168
  console.log('executeWithFile u8a', u8a)
170
169
  //execute
171
170
  await execute('10mb.7z', u8a)
172
171
  }
173
172
  core()
174
173
  let core = async() => {
175
174
  //u8a
176
175
  let u8a = new Uint8Array(fs.readFileSync('../_data/1000mb.7z'))
177
176
  console.log('u8a.length', u8a.length)
178
177
  console.log('uploadLargeFile u8a', u8a)
179
178
  await wo.upload('1000mb.7z', u8a,
180
179
  function (prog, p, m) {
181
180
  console.log('client web: upload: prog', prog, p, m)
182
181
  })
183
182
  .then(function(res) {
184
183
  console.log('client web: upload: then', res)
185
184
  })
186
185
  .catch(function (err) {
187
186
  console.log('client web: upload: catch', err)
188
187
  })
189
188
  }
190
189
  core()
190
+ <pre class="prettyprint"><code>import WConverhpClient from 'w-converhp/dist/w-converhp-client.umd.js'
191
191
  FormData,
192
192
  url: 'http://localhost:8080',
193
193
  apiName: 'api',
194
194
  //p
195
195
  let p = {
196
196
  a: 12,
197
197
  b: 34.56,
198
198
  c: 'test中文',
199
199
  d: {
200
200
  name,
201
201
  u8a,
202
202
  },
203
203
  }
204
204
  console.log('p', p)
205
205
  //execute
206
206
  await wo.execute('add', { p },
207
207
  function ({ prog, p, m }) {
208
208
  console.log('client web: execute: prog', prog, p, m)
209
209
  })
210
210
  .then(function(r) {
211
211
  console.log('client web: execute: add', r)
212
212
  console.log('r._bin.name', r._bin.name, 'r._bin.u8a', r._bin.u8a)
213
213
  // w.downloadFileFromU8Arr(r._bin.name, r._bin.u8a)
214
214
  })
215
215
  .catch(function (err) {
216
216
  console.log('client web: execute: catch', err)
217
217
  })
218
218
  let core = async() => {
219
219
  //u8a
220
220
  let u8a = new Uint8Array([66, 97, 115])
221
221
  console.log('executeWithU8a u8a', u8a)
222
222
  //execute
223
223
  await execute('zdata.b1', u8a)
224
224
  }
225
225
  core()
226
226
  let core = async() => {
227
227
  //u8a
228
228
  let u8a = new Uint8Array(fs.readFileSync('../_data/10mb.7z'))
229
229
  console.log('executeWithFile u8a', u8a)
230
230
  //execute
231
231
  await execute('10mb.7z', u8a)
232
232
  }
233
233
  core()
234
234
  let core = async() => {
235
235
  //u8a
236
236
  let u8a = new Uint8Array(fs.readFileSync('../_data/1000mb.7z'))
237
237
  console.log('u8a.length', u8a.length)
238
238
  console.log('uploadLargeFile u8a', u8a)
239
239
  await wo.upload('1000mb.7z', u8a,
240
240
  function ({ prog, p, m }) {
241
241
  console.log('client web: upload: prog', prog, p, m)
242
242
  })
243
243
  .then(function(res) {
244
244
  console.log('client web: upload: then', res)
245
245
  })
246
246
  .catch(function (err) {
247
247
  console.log('client web: upload: catch', err)
248
248
  })
249
249
  }
250
250
  core()
251
251
 
252
252
 
253
253
 
@@ -322,6 +322,46 @@
322
322
 
323
323
 
324
324
 
325
+ <tr>
326
+
327
+ <td class="name"><code>tokenType</code></td>
328
+
329
+
330
+ <td class="type">
331
+
332
+
333
+ <span class="param-type">String</span>
334
+
335
+
336
+
337
+
338
+ </td>
339
+
340
+
341
+ <td class="attributes">
342
+
343
+ &lt;optional><br>
344
+
345
+
346
+
347
+
348
+
349
+ </td>
350
+
351
+
352
+
353
+ <td class="default">
354
+
355
+ <code>'Bearer'</code>
356
+
357
+ </td>
358
+
359
+
360
+ <td class="description last"><p>輸入token類型字串,預設'Bearer'</p></td>
361
+ </tr>
362
+
363
+
364
+
325
365
  <tr>
326
366
 
327
367
  <td class="name"><code>sizeSlice</code></td>
@@ -489,7 +529,7 @@
489
529
  <br class="clear">
490
530
 
491
531
  <footer>
492
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 19:42:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
532
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
493
533
  </footer>
494
534
 
495
535
  <script>prettyPrint();</script>
@@ -76,6 +76,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
76
76
  * @param {String} [opt.url='http://localhost:8080'] 輸入Hapi伺服器網址,預設為'http://localhost:8080'
77
77
  * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
78
78
  * @param {Function} [opt.getToken=()=>''] 輸入取得使用者token的回調函數,預設()=>''
79
+ * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
79
80
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
80
81
  * @param {Integer} [opt.retry=3] 輸入傳輸失敗重試次數整數,預設為3
81
82
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
@@ -108,7 +109,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
108
109
  *
109
110
  * //execute
110
111
  * await wo.execute('add', { p },
111
- * function (prog, p, m) {
112
+ * function ({ prog, p, m }) {
112
113
  * console.log('client web: execute: prog', prog, p, m)
113
114
  * })
114
115
  * .then(function(r) {
@@ -161,7 +162,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
161
162
  * console.log('uploadLargeFile u8a', u8a)
162
163
  *
163
164
  * await wo.upload('1000mb.7z', u8a,
164
- * function (prog, p, m) {
165
+ * function ({ prog, p, m }) {
165
166
  * console.log('client web: upload: prog', prog, p, m)
166
167
  * })
167
168
  * .then(function(res) {
@@ -208,6 +209,12 @@ function WConverhpClient(opt) {
208
209
  }
209
210
  }
210
211
 
212
+ //tokenType
213
+ let tokenType = get(opt, 'tokenType')
214
+ if (!isestr(tokenType)) {
215
+ tokenType = 'Bearer'
216
+ }
217
+
211
218
  //sizeSlice
212
219
  let sizeSlice = get(opt, 'sizeSlice')
213
220
  if (!ispint(sizeSlice)) {
@@ -383,7 +390,7 @@ function WConverhpClient(opt) {
383
390
  url: urlUse,
384
391
  data: dd,
385
392
  headers: {
386
- Authorization: `Bearer ${token}`,
393
+ Authorization: `${tokenType} ${token}`,
387
394
  ...ct,
388
395
  ...headers,
389
396
  },
@@ -403,7 +410,7 @@ function WConverhpClient(opt) {
403
410
  }
404
411
 
405
412
  //cbProgress
406
- cbProgress(Math.floor(r), loaded, 'upload')
413
+ cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
407
414
 
408
415
  },
409
416
  onDownloadProgress: function (ev) {
@@ -419,7 +426,7 @@ function WConverhpClient(opt) {
419
426
  }
420
427
 
421
428
  //cbProgress
422
- cbProgress(Math.floor(r), loaded, 'download')
429
+ cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
423
430
 
424
431
  },
425
432
  }
@@ -601,20 +608,24 @@ function WConverhpClient(opt) {
601
608
  // let progWeightMerge = 0.01 //合併階段進度使用1%
602
609
 
603
610
  //cbProgressSlice
604
- let cbProgressSlice = (perc, _psiz, dir) => {
611
+ let cbProgressSlice = (msg) => {
612
+ let perc = msg.prog
613
+ let dir = msg.m
605
614
  if (dir === 'upload' &amp;&amp; perc === 100) {
606
615
  progCount++
607
616
  let r = progCount / chunkTotal
608
617
  let prog = r * progWeightSlice * 100
609
618
  let psiz = r * n
610
- cbProgress(prog, psiz, 'upload')
619
+ cbProgress({ prog, p: psiz, m: 'upload' })
611
620
  }
612
621
  }
613
622
 
614
623
  //cbProgressMerge
615
- let cbProgressMerge = (perc, _psiz, dir) => {
624
+ let cbProgressMerge = (msg) => {
625
+ let perc = msg.prog
626
+ let dir = msg.m
616
627
  if (dir === 'download' &amp;&amp; perc === 100) {
617
- cbProgress(100, n, 'upload')
628
+ cbProgress({ prog: 100, p: n, m: 'upload' })
618
629
  }
619
630
  }
620
631
 
@@ -755,7 +766,7 @@ export default WConverhpClient
755
766
  <br class="clear">
756
767
 
757
768
  <footer>
758
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 19:42:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
769
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
759
770
  </footer>
760
771
 
761
772
  <script>prettyPrint();</script>
@@ -709,7 +709,7 @@
709
709
  <br class="clear">
710
710
 
711
711
  <footer>
712
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 19:42:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
712
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
713
713
  </footer>
714
714
 
715
715
  <script>prettyPrint();</script>
@@ -380,14 +380,14 @@ function WConverhpServer(opt = {}) {
380
380
 
381
381
  //token
382
382
  // let token = get(query, 'token', '')
383
- let token = get(headers, 'authorization', '')
384
- token = isestr(token) ? token : ''
383
+ let authorization = get(headers, 'authorization', '')
384
+ authorization = isestr(authorization) ? authorization : ''
385
385
 
386
386
  //check
387
387
  if (true) {
388
388
 
389
389
  //funCheck
390
- let m = funCheck({ apiType: 'main', token, headers, query })
390
+ let m = funCheck({ apiType: 'main', authorization, headers, query })
391
391
  if (ispm(m)) {
392
392
  m = await m
393
393
  }
@@ -538,14 +538,14 @@ function WConverhpServer(opt = {}) {
538
538
 
539
539
  //token
540
540
  // let token = get(query, 'token', '')
541
- let token = get(headers, 'authorization', '')
542
- token = isestr(token) ? token : ''
541
+ let authorization = get(headers, 'authorization', '')
542
+ authorization = isestr(authorization) ? authorization : ''
543
543
 
544
544
  //check
545
545
  if (true) {
546
546
 
547
547
  //funCheck
548
- let m = funCheck({ apiType: 'slice', token, headers, query })
548
+ let m = funCheck({ apiType: 'slice', authorization, headers, query })
549
549
  if (ispm(m)) {
550
550
  m = await m
551
551
  }
@@ -684,14 +684,14 @@ function WConverhpServer(opt = {}) {
684
684
 
685
685
  //token
686
686
  // let token = get(query, 'token', '')
687
- let token = get(headers, 'authorization', '')
688
- token = isestr(token) ? token : ''
687
+ let authorization = get(headers, 'authorization', '')
688
+ authorization = isestr(authorization) ? authorization : ''
689
689
 
690
690
  //check
691
691
  if (true) {
692
692
 
693
693
  //funCheck
694
- let m = funCheck({ apiType: 'merge', token, headers, query })
694
+ let m = funCheck({ apiType: 'merge', authorization, headers, query })
695
695
  if (ispm(m)) {
696
696
  m = await m
697
697
  }
@@ -911,7 +911,7 @@ export default WConverhpServer
911
911
  <br class="clear">
912
912
 
913
913
  <footer>
914
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 19:42:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
914
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 21:48:05 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
915
915
  </footer>
916
916
 
917
917
  <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 Sun Mar 30 2025 19:42:30 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 Mar 30 2025 21:48:05 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.2",
3
+ "version": "2.0.4",
4
4
  "main": "dist/w-converhp-server.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.0",
package/scla.mjs CHANGED
@@ -36,7 +36,7 @@ async function execute(name, u8a) {
36
36
 
37
37
  //execute
38
38
  await wo.execute('add', { p },
39
- function (prog, p, m) {
39
+ function ({ prog, p, m }) {
40
40
  if (m === 'upload') {
41
41
  console.log('client web: execute: prog', prog * 0.5, p, m)
42
42
  }
package/sclb.mjs CHANGED
@@ -36,7 +36,7 @@ async function execute(name, u8a) {
36
36
 
37
37
  //execute
38
38
  await wo.execute('add', { p },
39
- function (prog, p, m) {
39
+ function ({ prog, p, m }) {
40
40
  if (m === 'upload') {
41
41
  console.log('client web: execute: prog', prog * 0.5, p, m)
42
42
  }
package/sclc.mjs CHANGED
@@ -29,7 +29,7 @@ function uploadLargeFile() {
29
29
  console.log('uploadLargeFile u8a', u8a)
30
30
 
31
31
  await wo.upload('1000mb.7z', u8a,
32
- function (prog, p, m) {
32
+ function ({ prog, p, m }) {
33
33
  // console.log('client web: upload: prog', prog, p, m)
34
34
  if (m === 'upload') {
35
35
  console.log('client web: upload: prog', prog)
@@ -29,6 +29,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
29
29
  * @param {String} [opt.url='http://localhost:8080'] 輸入Hapi伺服器網址,預設為'http://localhost:8080'
30
30
  * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
31
31
  * @param {Function} [opt.getToken=()=>''] 輸入取得使用者token的回調函數,預設()=>''
32
+ * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
32
33
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
33
34
  * @param {Integer} [opt.retry=3] 輸入傳輸失敗重試次數整數,預設為3
34
35
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
@@ -61,7 +62,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
61
62
  *
62
63
  * //execute
63
64
  * await wo.execute('add', { p },
64
- * function (prog, p, m) {
65
+ * function ({ prog, p, m }) {
65
66
  * console.log('client web: execute: prog', prog, p, m)
66
67
  * })
67
68
  * .then(function(r) {
@@ -114,7 +115,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
114
115
  * console.log('uploadLargeFile u8a', u8a)
115
116
  *
116
117
  * await wo.upload('1000mb.7z', u8a,
117
- * function (prog, p, m) {
118
+ * function ({ prog, p, m }) {
118
119
  * console.log('client web: upload: prog', prog, p, m)
119
120
  * })
120
121
  * .then(function(res) {
@@ -161,6 +162,12 @@ function WConverhpClient(opt) {
161
162
  }
162
163
  }
163
164
 
165
+ //tokenType
166
+ let tokenType = get(opt, 'tokenType')
167
+ if (!isestr(tokenType)) {
168
+ tokenType = 'Bearer'
169
+ }
170
+
164
171
  //sizeSlice
165
172
  let sizeSlice = get(opt, 'sizeSlice')
166
173
  if (!ispint(sizeSlice)) {
@@ -336,7 +343,7 @@ function WConverhpClient(opt) {
336
343
  url: urlUse,
337
344
  data: dd,
338
345
  headers: {
339
- Authorization: `Bearer ${token}`,
346
+ Authorization: `${tokenType} ${token}`,
340
347
  ...ct,
341
348
  ...headers,
342
349
  },
@@ -356,7 +363,7 @@ function WConverhpClient(opt) {
356
363
  }
357
364
 
358
365
  //cbProgress
359
- cbProgress(Math.floor(r), loaded, 'upload')
366
+ cbProgress({ prog: Math.floor(r), p: loaded, m: 'upload' })
360
367
 
361
368
  },
362
369
  onDownloadProgress: function (ev) {
@@ -372,7 +379,7 @@ function WConverhpClient(opt) {
372
379
  }
373
380
 
374
381
  //cbProgress
375
- cbProgress(Math.floor(r), loaded, 'download')
382
+ cbProgress({ prog: Math.floor(r), p: loaded, m: 'download' })
376
383
 
377
384
  },
378
385
  }
@@ -554,20 +561,24 @@ function WConverhpClient(opt) {
554
561
  // let progWeightMerge = 0.01 //合併階段進度使用1%
555
562
 
556
563
  //cbProgressSlice
557
- let cbProgressSlice = (perc, _psiz, dir) => {
564
+ let cbProgressSlice = (msg) => {
565
+ let perc = msg.prog
566
+ let dir = msg.m
558
567
  if (dir === 'upload' && perc === 100) {
559
568
  progCount++
560
569
  let r = progCount / chunkTotal
561
570
  let prog = r * progWeightSlice * 100
562
571
  let psiz = r * n
563
- cbProgress(prog, psiz, 'upload')
572
+ cbProgress({ prog, p: psiz, m: 'upload' })
564
573
  }
565
574
  }
566
575
 
567
576
  //cbProgressMerge
568
- let cbProgressMerge = (perc, _psiz, dir) => {
577
+ let cbProgressMerge = (msg) => {
578
+ let perc = msg.prog
579
+ let dir = msg.m
569
580
  if (dir === 'download' && perc === 100) {
570
- cbProgress(100, n, 'upload')
581
+ cbProgress({ prog: 100, p: n, m: 'upload' })
571
582
  }
572
583
  }
573
584
 
@@ -333,14 +333,14 @@ function WConverhpServer(opt = {}) {
333
333
 
334
334
  //token
335
335
  // let token = get(query, 'token', '')
336
- let token = get(headers, 'authorization', '')
337
- token = isestr(token) ? token : ''
336
+ let authorization = get(headers, 'authorization', '')
337
+ authorization = isestr(authorization) ? authorization : ''
338
338
 
339
339
  //check
340
340
  if (true) {
341
341
 
342
342
  //funCheck
343
- let m = funCheck({ apiType: 'main', token, headers, query })
343
+ let m = funCheck({ apiType: 'main', authorization, headers, query })
344
344
  if (ispm(m)) {
345
345
  m = await m
346
346
  }
@@ -491,14 +491,14 @@ function WConverhpServer(opt = {}) {
491
491
 
492
492
  //token
493
493
  // let token = get(query, 'token', '')
494
- let token = get(headers, 'authorization', '')
495
- token = isestr(token) ? token : ''
494
+ let authorization = get(headers, 'authorization', '')
495
+ authorization = isestr(authorization) ? authorization : ''
496
496
 
497
497
  //check
498
498
  if (true) {
499
499
 
500
500
  //funCheck
501
- let m = funCheck({ apiType: 'slice', token, headers, query })
501
+ let m = funCheck({ apiType: 'slice', authorization, headers, query })
502
502
  if (ispm(m)) {
503
503
  m = await m
504
504
  }
@@ -637,14 +637,14 @@ function WConverhpServer(opt = {}) {
637
637
 
638
638
  //token
639
639
  // let token = get(query, 'token', '')
640
- let token = get(headers, 'authorization', '')
641
- token = isestr(token) ? token : ''
640
+ let authorization = get(headers, 'authorization', '')
641
+ authorization = isestr(authorization) ? authorization : ''
642
642
 
643
643
  //check
644
644
  if (true) {
645
645
 
646
646
  //funCheck
647
- let m = funCheck({ apiType: 'merge', token, headers, query })
647
+ let m = funCheck({ apiType: 'merge', authorization, headers, query })
648
648
  if (ispm(m)) {
649
649
  m = await m
650
650
  }
package/srv.mjs CHANGED
@@ -1,13 +1,19 @@
1
1
  import fs from 'fs'
2
2
  import _ from 'lodash-es'
3
+ import w from 'wsemi'
3
4
  import WConverhpServer from './src/WConverhpServer.mjs'
4
5
 
5
6
  let opt = {
6
7
  port: 8080,
7
8
  apiName: 'api',
8
9
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
9
- funCheck: ({ apiType, token, headers, query }) => {
10
- console.log('funCheck', apiType, token)
10
+ funCheck: async ({ apiType, authorization, headers, query }) => {
11
+ console.log('funCheck', `apiType[${apiType}]`, `authorization[${authorization}]`)
12
+ let token = w.strdelleft(authorization, 7) //刪除Bearer
13
+ if (!w.isestr(token)) {
14
+ return false
15
+ }
16
+ // await w.delay(3000)
11
17
  return true
12
18
  },
13
19
  }
package/web.html CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
  //execute
52
52
  await wo.execute('add', { p },
53
- function (prog, p, m) {
53
+ function ({ prog, p, m }) {
54
54
  console.log('client web: execute: prog', prog, p, m)
55
55
  })
56
56
  .then(function(r) {
@@ -132,7 +132,7 @@
132
132
 
133
133
  //upload
134
134
  await wo.upload(file.name, file,
135
- function (prog, p, m) {
135
+ function ({ prog, p, m }) {
136
136
  console.log('client web: upload: prog', prog, p, m)
137
137
  })
138
138
  .then(function(res) {