w-web-api 1.0.22 → 1.0.24

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.
Files changed (44) hide show
  1. package/.eslintrc.js +18 -17
  2. package/.github/workflows/ci-test.yml +24 -0
  3. package/.vscode/launch.json +21 -0
  4. package/README.md +21 -4
  5. package/babel.config.js +1 -0
  6. package/dist/css/{chunk-vendors.b4caa718.css → chunk-vendors.ca61ed63.css} +1 -1
  7. package/dist/img/connecting.26511805.svg +10 -0
  8. package/dist/img/deny.e7b81b94.png +0 -0
  9. package/dist/index.tmp +1 -1
  10. package/dist/js/app-legacy.8589a7d0.js +2 -0
  11. package/dist/js/app-legacy.8589a7d0.js.map +1 -0
  12. package/dist/js/app.8589a7d0.js +2 -0
  13. package/dist/js/app.8589a7d0.js.map +1 -0
  14. package/dist/js/chunk-vendors-legacy.4a6f42ee.js +14 -0
  15. package/dist/js/chunk-vendors-legacy.4a6f42ee.js.map +1 -0
  16. package/dist/js/chunk-vendors.4a6f42ee.js +14 -0
  17. package/dist/js/chunk-vendors.4a6f42ee.js.map +1 -0
  18. package/dist/w-web-api.umd.js +2 -2
  19. package/dist/w-web-api.umd.js.map +1 -1
  20. package/docs/WWebApi.html +111 -23
  21. package/docs/WWebApi.mjs.html +152 -30
  22. package/docs/index.html +4 -1
  23. package/docs/scripts/collapse.js +19 -0
  24. package/docs/scripts/commonNav.js +28 -0
  25. package/docs/scripts/search.js +16 -0
  26. package/docs/styles/jsdoc.css +13 -2
  27. package/docs/styles/prettify.css +1 -0
  28. package/g.getSettings.mjs +1 -1
  29. package/package.json +24 -24
  30. package/server/WWebApi.mjs +148 -29
  31. package/src/App.vue +63 -5
  32. package/src/components/Layout.vue +1 -0
  33. package/src/components/LayoutState.vue +87 -0
  34. package/src/main.js +5 -2
  35. package/src/plugins/mUI.mjs +12 -0
  36. package/src/store/mutations.mjs +13 -6
  37. package/srv.mjs +21 -2
  38. package/tableTags-web-api.json +1 -1
  39. package/test/all.test.mjs +10 -0
  40. package/dist/js/app.32beae37.js +0 -2
  41. package/dist/js/app.32beae37.js.map +0 -1
  42. package/dist/js/chunk-vendors.69cb98c3.js +0 -24
  43. package/dist/js/chunk-vendors.69cb98c3.js.map +0 -1
  44. /package/dist/css/{app.5b03c2b6.css → app.e645631b.css} +0 -0
package/docs/WWebApi.html CHANGED
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
31
+
30
32
  <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="WWebApi.html">WWebApi</a></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -45,7 +48,9 @@
45
48
  <header>
46
49
 
47
50
  <h2>
48
- WWebApi
51
+
52
+ WWebApi
53
+
49
54
  </h2>
50
55
 
51
56
 
@@ -59,7 +64,7 @@
59
64
 
60
65
 
61
66
 
62
- <h4 class="name" id="WWebApi"><span class="type-signature"></span>new WWebApi<span class="signature">(WOrm, url, db, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
67
+ <h4 class="name" id="WWebApi"><span class="type-signature"></span>new WWebApi<span class="signature">(WOrm, url, db, getUserByToken, verifyUser, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
63
68
 
64
69
 
65
70
 
@@ -67,11 +72,15 @@
67
72
 
68
73
 
69
74
  <dl class="details">
75
+
76
+ <dt class="tag-description">Description:</dt>
77
+ <dd class="tag-description"><ul class="dummy"><li><p>基於hapi之API伺服器</p></li></ul></dd>
78
+
70
79
 
71
80
 
72
81
  <dt class="tag-source">Source:</dt>
73
82
  <dd class="tag-source"><ul class="dummy"><li>
74
- <a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#line78">line 78</a>
83
+ <a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#line82">line 82</a>
75
84
  </li></ul></dd>
76
85
 
77
86
 
@@ -110,26 +119,20 @@
110
119
 
111
120
 
112
121
 
113
- <div class="description usertext">
114
- <p>基於hapi之API伺服器</p>
115
- </div>
116
-
117
-
118
122
 
119
123
 
120
124
 
121
125
 
122
126
 
123
127
 
124
-
125
- <h5>Example</h5>
128
+ <h5 class="h5-examples">Example</h5>
126
129
 
127
130
  <pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
128
131
  getUserById: null,
129
132
  bCheckUser: false,
130
133
  bExcludeWhenNotAdmin: false,
131
134
  serverPort: 11005,
132
135
  subfolder: '', //mpai
133
136
  webName: {
134
137
  'eng': 'API Service',
135
138
  'cht': 'API管理系統'
136
139
  },
137
140
  console.log(err)
138
141
 
139
142
 
140
143
 
141
144
 
142
- <h5>Parameters:</h5>
145
+ <h5 class="h5-parameters">Parameters:</h5>
143
146
 
144
147
 
145
148
  <table class="params">
@@ -167,6 +170,7 @@
167
170
  <span class="param-type">function</span>
168
171
 
169
172
 
173
+
170
174
 
171
175
  </td>
172
176
 
@@ -202,6 +206,7 @@
202
206
  <span class="param-type">String</span>
203
207
 
204
208
 
209
+
205
210
 
206
211
  </td>
207
212
 
@@ -237,6 +242,7 @@
237
242
  <span class="param-type">String</span>
238
243
 
239
244
 
245
+
240
246
 
241
247
  </td>
242
248
 
@@ -261,6 +267,78 @@
261
267
 
262
268
 
263
269
 
270
+ <tr>
271
+
272
+ <td class="name"><code>getUserByToken</code></td>
273
+
274
+
275
+ <td class="type">
276
+
277
+
278
+ <span class="param-type">function</span>
279
+
280
+
281
+
282
+
283
+ </td>
284
+
285
+
286
+ <td class="attributes">
287
+
288
+
289
+
290
+
291
+
292
+ </td>
293
+
294
+
295
+
296
+ <td class="default">
297
+
298
+ </td>
299
+
300
+
301
+ <td class="description last"><p>輸入處理函數,函數會傳入使用者token,通過此函數處理後並回傳使用者資訊物件,並至少須提供'id'、'email'、'name'、'isAdmin'欄位,且'isAdmin'限輸入'y'或'n',且輸入'y'時會複寫權限系統該使用者之'isAdmin'欄位值</p></td>
302
+ </tr>
303
+
304
+
305
+
306
+ <tr>
307
+
308
+ <td class="name"><code>verifyUser</code></td>
309
+
310
+
311
+ <td class="type">
312
+
313
+
314
+ <span class="param-type">function</span>
315
+
316
+
317
+
318
+
319
+ </td>
320
+
321
+
322
+ <td class="attributes">
323
+
324
+
325
+
326
+
327
+
328
+ </td>
329
+
330
+
331
+
332
+ <td class="default">
333
+
334
+ </td>
335
+
336
+
337
+ <td class="description last"><p>輸入處理函數,函數會傳入使用者資訊物件,通過此函數識別後回傳布林值,允許使用者回傳true,反之回傳false</p></td>
338
+ </tr>
339
+
340
+
341
+
264
342
  <tr>
265
343
 
266
344
  <td class="name"><code>opt</code></td>
@@ -272,6 +350,7 @@
272
350
  <span class="param-type">Object</span>
273
351
 
274
352
 
353
+
275
354
 
276
355
  </td>
277
356
 
@@ -334,6 +413,7 @@
334
413
  <span class="param-type">Integer</span>
335
414
 
336
415
 
416
+
337
417
 
338
418
  </td>
339
419
 
@@ -364,13 +444,14 @@
364
444
 
365
445
  <tr>
366
446
 
367
- <td class="name"><code>getUserById</code></td>
447
+ <td class="name"><code>bCheckUser</code></td>
368
448
 
369
449
 
370
450
  <td class="type">
371
451
 
372
452
 
373
- <span class="param-type">function</span>
453
+ <span class="param-type">Boolean</span>
454
+
374
455
 
375
456
 
376
457
 
@@ -391,25 +472,26 @@
391
472
 
392
473
  <td class="default">
393
474
 
394
- <code>null</code>
475
+ <code>false</code>
395
476
 
396
477
  </td>
397
478
 
398
479
 
399
- <td class="description last"><p>輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null</p></td>
480
+ <td class="description last"><p>輸入是否檢查使用者資訊布林值,預設false</p></td>
400
481
  </tr>
401
482
 
402
483
 
403
484
 
404
485
  <tr>
405
486
 
406
- <td class="name"><code>bCheckUser</code></td>
487
+ <td class="name"><code>getUserById</code></td>
407
488
 
408
489
 
409
490
  <td class="type">
410
491
 
411
492
 
412
- <span class="param-type">Boolean</span>
493
+ <span class="param-type">function</span>
494
+
413
495
 
414
496
 
415
497
 
@@ -430,12 +512,12 @@
430
512
 
431
513
  <td class="default">
432
514
 
433
- <code>true</code>
515
+ <code>null</code>
434
516
 
435
517
  </td>
436
518
 
437
519
 
438
- <td class="description last"><p>輸入是否檢查使用者資訊布林值,預設true</p></td>
520
+ <td class="description last"><p>輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null</p></td>
439
521
  </tr>
440
522
 
441
523
 
@@ -451,6 +533,7 @@
451
533
  <span class="param-type">Boolean</span>
452
534
 
453
535
 
536
+
454
537
 
455
538
  </td>
456
539
 
@@ -469,12 +552,12 @@
469
552
 
470
553
  <td class="default">
471
554
 
472
- <code>true</code>
555
+ <code>false</code>
473
556
 
474
557
  </td>
475
558
 
476
559
 
477
- <td class="description last"><p>輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設true</p></td>
560
+ <td class="description last"><p>輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設false</p></td>
478
561
  </tr>
479
562
 
480
563
 
@@ -490,6 +573,7 @@
490
573
  <span class="param-type">Object</span>
491
574
 
492
575
 
576
+
493
577
 
494
578
  </td>
495
579
 
@@ -529,6 +613,7 @@
529
613
  <span class="param-type">Object</span>
530
614
 
531
615
 
616
+
532
617
 
533
618
  </td>
534
619
 
@@ -568,6 +653,7 @@
568
653
  <span class="param-type">String</span>
569
654
 
570
655
 
656
+
571
657
 
572
658
  </td>
573
659
 
@@ -607,6 +693,7 @@
607
693
  <span class="param-type">String</span>
608
694
 
609
695
 
696
+
610
697
 
611
698
  </td>
612
699
 
@@ -659,7 +746,7 @@
659
746
 
660
747
 
661
748
 
662
- <h5>Returns:</h5>
749
+ <h5 class="h5-returns">Returns:</h5>
663
750
 
664
751
 
665
752
  <div class="param-desc">
@@ -677,6 +764,7 @@
677
764
  <span class="param-type">Object</span>
678
765
 
679
766
 
767
+
680
768
  </dd>
681
769
  </dl>
682
770
 
@@ -721,7 +809,7 @@
721
809
  <br class="clear">
722
810
 
723
811
  <footer>
724
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Mon Jan 23 2023 21:06:06 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
812
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jun 18 2023 18:26:06 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
725
813
  </footer>
726
814
 
727
815
  <script>prettyPrint();</script>
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
31
+
30
32
  <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="WWebApi.html">WWebApi</a></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -54,17 +57,19 @@ import iseobj from 'wsemi/src/iseobj.mjs'
54
57
  import isestr from 'wsemi/src/isestr.mjs'
55
58
  import ispint from 'wsemi/src/ispint.mjs'
56
59
  import isfun from 'wsemi/src/isfun.mjs'
60
+ import ispm from 'wsemi/src/ispm.mjs'
57
61
  import cint from 'wsemi/src/cint.mjs'
58
62
  import strleft from 'wsemi/src/strleft.mjs'
59
63
  import strdelleft from 'wsemi/src/strdelleft.mjs'
60
64
  import strright from 'wsemi/src/strright.mjs'
61
65
  import strdelright from 'wsemi/src/strdelright.mjs'
66
+ import pm2resolve from 'wsemi/src/pm2resolve.mjs'
62
67
  import b642str from 'wsemi/src/b642str.mjs'
63
68
  import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
64
69
  import replace from 'wsemi/src/replace.mjs'
65
70
  import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
66
- import ds from '../src/schema/index.mjs'
67
71
  import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
72
+ import ds from '../src/schema/index.mjs'
68
73
 
69
74
 
70
75
  /**
@@ -74,11 +79,13 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
74
79
  * @param {Function} WOrm 輸入資料庫ORM函數
75
80
  * @param {String} url 輸入資料庫連線字串,例如'mongodb://sername:password@$127.0.0.1:27017'
76
81
  * @param {String} db 輸入資料庫名稱字串
82
+ * @param {Function} getUserByToken 輸入處理函數,函數會傳入使用者token,通過此函數處理後並回傳使用者資訊物件,並至少須提供'id'、'email'、'name'、'isAdmin'欄位,且'isAdmin'限輸入'y'或'n',且輸入'y'時會複寫權限系統該使用者之'isAdmin'欄位值
83
+ * @param {Function} verifyUser 輸入處理函數,函數會傳入使用者資訊物件,通過此函數識別後回傳布林值,允許使用者回傳true,反之回傳false
77
84
  * @param {Object} [opt={}] 輸入設定物件,預設{}
78
85
  * @param {Integer} [opt.serverPort=11005] 輸入伺服器通訊port,預設11005
86
+ * @param {Boolean} [opt.bCheckUser=false] 輸入是否檢查使用者資訊布林值,預設false
79
87
  * @param {Function} [opt.getUserById=null] 輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null
80
- * @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
81
- * @param {Boolean} [opt.bExcludeWhenNotAdmin=true] 輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設true
88
+ * @param {Boolean} [opt.bExcludeWhenNotAdmin=false] 輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設false
82
89
  * @param {Object} [opt.webName={}] 輸入站台名稱物件,至少包含語系eng與cht鍵的名稱,預設{}
83
90
  * @param {Object} [opt.webDescription={}] 輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}
84
91
  * @param {String} [opt.webLogo=''] 輸入站台logo字串,採base64格式,預設''
@@ -119,7 +126,7 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
119
126
  * })
120
127
  *
121
128
  */
122
- function WWebApi(WOrm, url, db, opt = {}) {
129
+ function WWebApi(WOrm, url, db, getUserByToken, verifyUser, opt = {}) {
123
130
  let instWServHapiServer = null
124
131
 
125
132
 
@@ -144,6 +151,20 @@ function WWebApi(WOrm, url, db, opt = {}) {
144
151
  }
145
152
 
146
153
 
154
+ //check getUserByToken
155
+ if (!isfun(getUserByToken)) {
156
+ console.log('invalid getUserByToken', getUserByToken)
157
+ throw new Error('invalid getUserByToken')
158
+ }
159
+
160
+
161
+ //check verifyUser
162
+ if (!isfun(verifyUser)) {
163
+ console.log('invalid verifyUser', verifyUser)
164
+ throw new Error('invalid verifyUser')
165
+ }
166
+
167
+
147
168
  //serverPort
148
169
  let serverPort = get(opt, 'serverPort')
149
170
  if (!ispint(serverPort)) {
@@ -214,9 +235,35 @@ function WWebApi(WOrm, url, db, opt = {}) {
214
235
  }
215
236
 
216
237
 
238
+ //verifyUserByToken
239
+ let verifyUserByToken = async (token) => {
240
+
241
+ //getUserByToken
242
+ let user = getUserByToken(token)
243
+ if (ispm(user)) {
244
+ user = await user
245
+ }
246
+ if (!iseobj(user)) {
247
+ return Promise.reject(`token does not have permission`)
248
+ }
249
+
250
+ //verifyUser
251
+ let b = verifyUser(user)
252
+ if (ispm(b)) {
253
+ b = await b
254
+ }
255
+
256
+ //check
257
+ if (!b) {
258
+ return Promise.reject(`user does not have permission`)
259
+ }
260
+
261
+ return user
262
+ }
263
+
217
264
  //getAPIsList
218
- let getAPIsList = async (userId, token) => {
219
- let rs = await woItems.apis.select()
265
+ let getAPIsList = async (query = {}) => {
266
+ let rs = await woItems.apis.select(query)
220
267
  return rs
221
268
  }
222
269
 
@@ -266,7 +313,7 @@ function WWebApi(WOrm, url, db, opt = {}) {
266
313
 
267
314
 
268
315
  //updateAPIs
269
- let updateAPIs = async (userId, params = {}) => {
316
+ let updateAPIs = async (params = {}) => {
270
317
 
271
318
  //spread params
272
319
  let { apis: rsApis } = params
@@ -281,7 +328,7 @@ function WWebApi(WOrm, url, db, opt = {}) {
281
328
 
282
329
 
283
330
  //replaceAPIsByLevels
284
- let replaceAPIsByLevels = async (userId, params = {}) => {
331
+ let replaceAPIsByLevels = async (params = {}) => {
285
332
 
286
333
  //spread params
287
334
  let { group, apis: rsApis } = params
@@ -310,11 +357,17 @@ function WWebApi(WOrm, url, db, opt = {}) {
310
357
  //subfolder
311
358
  let fnEntryIn = 'index.tmp'
312
359
  let fnEntryOut = 'index.html'
313
- let fpEntryIn = path.resolve(pathStaticFiles, fnEntryIn)
314
- let fpEntryOut = path.resolve(pathStaticFiles, fnEntryOut)
315
- let c = fs.readFileSync(fpEntryIn, 'utf8')
316
- c = replace(c, '{sfd}', subfolder)
317
- fs.writeFileSync(fpEntryOut, c, 'utf8')
360
+ try {
361
+ let fpEntryIn = path.resolve(pathStaticFiles, fnEntryIn)
362
+ let fpEntryOut = path.resolve(pathStaticFiles, fnEntryOut)
363
+ let c = fs.readFileSync(fpEntryIn, 'utf8')
364
+ c = replace(c, '{sfd}', subfolder)
365
+ fs.writeFileSync(fpEntryOut, c, 'utf8')
366
+ }
367
+ catch (err) {
368
+ console.log(err)
369
+ console.log(`can not generate ${fnEntryOut}`)
370
+ }
318
371
 
319
372
 
320
373
  //apis
@@ -337,16 +390,53 @@ function WWebApi(WOrm, url, db, opt = {}) {
337
390
  return getWebInfor()
338
391
  },
339
392
  },
393
+ {
394
+ method: 'GET',
395
+ path: '/api/getUserByToken', //未登入界面需先檢測token是否為系統管理員, 確認後回傳為系統管理員資訊物件
396
+ handler: async function (req, res) {
397
+ // console.log('getUserByToken', req)
398
+
399
+ async function core() {
400
+
401
+ //token
402
+ let token = get(req, 'query.token', '')
403
+
404
+ //verifyUserByToken
405
+ let user = await verifyUserByToken(token)
406
+
407
+ return user
408
+ }
409
+
410
+ //pm2resolve core
411
+ let r = await pm2resolve(core)()
412
+ // console.log('verifyIdentity', r)
413
+
414
+ return r
415
+ },
416
+ },
340
417
  {
341
418
  method: 'GET',
342
419
  path: '/getAPIsList',
343
420
  handler: async function (req, res) {
421
+ // console.log('getAPIsList', req)
422
+
423
+ async function core() {
424
+
425
+ //token
426
+ let token = get(req, 'query.token', '')
344
427
 
345
- //token
346
- let token = get(req, 'query.token', '')
428
+ //verifyUserByToken
429
+ await verifyUserByToken(token)
347
430
 
348
- //getAPIsList
349
- let r = await getAPIsList('', token)
431
+ //getAPIsList
432
+ let r = await getAPIsList({ isActive: 'y' })
433
+
434
+ return r
435
+ }
436
+
437
+ //pm2resolve core
438
+ let r = await pm2resolve(core)()
439
+ // console.log('verifyIdentity', r)
350
440
 
351
441
  return r
352
442
  },
@@ -355,14 +445,29 @@ function WWebApi(WOrm, url, db, opt = {}) {
355
445
  method: 'POST',
356
446
  path: '/updateAPIs',
357
447
  handler: async function (req, res) {
358
- // console.log(req, res)
448
+ // console.log('updateAPIs', req)
359
449
  // console.log('payload', req.payload)
360
450
 
361
- //parsePayload
362
- let inp = parsePayload(req)
451
+ async function core() {
452
+
453
+ //token
454
+ let token = get(req, 'query.token', '')
455
+
456
+ //verifyUserByToken
457
+ await verifyUserByToken(token)
458
+
459
+ //parsePayload
460
+ let inp = parsePayload(req)
461
+
462
+ //updateAPIs
463
+ let r = await updateAPIs(inp)
464
+
465
+ return r
466
+ }
363
467
 
364
- //updateAPIs
365
- let r = await updateAPIs('', inp)
468
+ //pm2resolve core
469
+ let r = await pm2resolve(core)()
470
+ // console.log('verifyIdentity', r)
366
471
 
367
472
  return r
368
473
  },
@@ -371,14 +476,29 @@ function WWebApi(WOrm, url, db, opt = {}) {
371
476
  method: 'POST',
372
477
  path: '/replaceAPIsByLevels',
373
478
  handler: async function (req, res) {
374
- // console.log(req, res)
479
+ // console.log('replaceAPIsByLevels', req)
375
480
  // console.log('payload', req.payload)
376
481
 
377
- //parsePayload
378
- let inp = parsePayload(req)
482
+ async function core() {
379
483
 
380
- //replaceAPIsByLevels
381
- let r = await replaceAPIsByLevels('', inp)
484
+ //token
485
+ let token = get(req, 'query.token', '')
486
+
487
+ //verifyUserByToken
488
+ await verifyUserByToken(token)
489
+
490
+ //parsePayload
491
+ let inp = parsePayload(req)
492
+
493
+ //replaceAPIsByLevels
494
+ let r = await replaceAPIsByLevels(inp)
495
+
496
+ return r
497
+ }
498
+
499
+ //pm2resolve core
500
+ let r = await pm2resolve(core)()
501
+ // console.log('verifyIdentity', r)
382
502
 
383
503
  return r
384
504
  },
@@ -400,7 +520,7 @@ function WWebApi(WOrm, url, db, opt = {}) {
400
520
  pathStaticFiles,
401
521
  apis,
402
522
  getUserIDFromToken: async (token) => { //可使用async或sync函數
403
- return 'id-for-admin'
523
+ return ''
404
524
  },
405
525
  useDbORM: true,
406
526
  dbORMs: woItems,
@@ -410,7 +530,9 @@ function WWebApi(WOrm, url, db, opt = {}) {
410
530
  tableNamesSync,
411
531
  extFuncs: { //接收參數第1個為userId, 之後才是前端給予參數
412
532
  getWebInfor,
413
- getAPIsList,
533
+ getAPIsList: (userId, query = {}) => {
534
+ return getAPIsList(query)
535
+ },
414
536
  //...
415
537
  },
416
538
  hookBefores: null,
@@ -438,7 +560,7 @@ export default WWebApi
438
560
  <br class="clear">
439
561
 
440
562
  <footer>
441
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Mon Jan 23 2023 21:06:06 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
563
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jun 18 2023 18:26:06 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
442
564
  </footer>
443
565
 
444
566
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -14,6 +14,7 @@
14
14
  <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
15
  <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
16
  <script src="scripts/nav.js" defer></script>
17
+
17
18
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
19
  </head>
19
20
  <body>
@@ -27,7 +28,9 @@
27
28
 
28
29
  <nav >
29
30
 
31
+
30
32
  <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="WWebApi.html">WWebApi</a></li></ul>
33
+
31
34
  </nav>
32
35
 
33
36
  <div id="main">
@@ -68,7 +71,7 @@
68
71
  <br class="clear">
69
72
 
70
73
  <footer>
71
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Mon Jan 23 2023 21:06:06 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 Jun 18 2023 18:26:06 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
72
75
  </footer>
73
76
 
74
77
  <script>prettyPrint();</script>