w-web-api 1.0.0 → 1.0.3
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/dist/w-web-api.umd.js +1 -1
- package/docs/WWebApi.html +78 -12
- package/docs/WWebApi.mjs.html +42 -25
- package/docs/index.html +1 -1
- package/package.json +82 -81
package/dist/w-web-api.umd.js
CHANGED
package/docs/WWebApi.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
|
|
72
72
|
<dt class="tag-source">Source:</dt>
|
|
73
73
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
74
|
-
<a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#
|
|
74
|
+
<a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#line36">line 36</a>
|
|
75
75
|
</li></ul></dd>
|
|
76
76
|
|
|
77
77
|
|
|
@@ -235,8 +235,6 @@
|
|
|
235
235
|
|
|
236
236
|
<td class="attributes">
|
|
237
237
|
|
|
238
|
-
<optional><br>
|
|
239
|
-
|
|
240
238
|
|
|
241
239
|
|
|
242
240
|
|
|
@@ -247,8 +245,6 @@
|
|
|
247
245
|
|
|
248
246
|
<td class="default">
|
|
249
247
|
|
|
250
|
-
<code>''</code>
|
|
251
|
-
|
|
252
248
|
</td>
|
|
253
249
|
|
|
254
250
|
|
|
@@ -274,8 +270,6 @@
|
|
|
274
270
|
|
|
275
271
|
<td class="attributes">
|
|
276
272
|
|
|
277
|
-
<optional><br>
|
|
278
|
-
|
|
279
273
|
|
|
280
274
|
|
|
281
275
|
|
|
@@ -286,12 +280,45 @@
|
|
|
286
280
|
|
|
287
281
|
<td class="default">
|
|
288
282
|
|
|
289
|
-
|
|
283
|
+
</td>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
<td class="description last"><p>輸入資料庫名稱字串</p></td>
|
|
287
|
+
</tr>
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
<tr>
|
|
292
|
+
|
|
293
|
+
<td class="name"><code>WOrm</code></td>
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
<td class="type">
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
<span class="param-type">function</span>
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
</td>
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
<td class="attributes">
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
</td>
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
<td class="default">
|
|
290
317
|
|
|
291
318
|
</td>
|
|
292
319
|
|
|
293
320
|
|
|
294
|
-
<td class="description last"><p
|
|
321
|
+
<td class="description last"><p>輸入資料庫ORM函數</p></td>
|
|
295
322
|
</tr>
|
|
296
323
|
|
|
297
324
|
|
|
@@ -325,12 +352,12 @@
|
|
|
325
352
|
|
|
326
353
|
<td class="default">
|
|
327
354
|
|
|
328
|
-
<code>
|
|
355
|
+
<code>11005</code>
|
|
329
356
|
|
|
330
357
|
</td>
|
|
331
358
|
|
|
332
359
|
|
|
333
|
-
<td class="description last"><p>輸入伺服器通訊port,預設
|
|
360
|
+
<td class="description last"><p>輸入伺服器通訊port,預設11005</p></td>
|
|
334
361
|
</tr>
|
|
335
362
|
|
|
336
363
|
|
|
@@ -451,6 +478,45 @@
|
|
|
451
478
|
</tr>
|
|
452
479
|
|
|
453
480
|
|
|
481
|
+
|
|
482
|
+
<tr>
|
|
483
|
+
|
|
484
|
+
<td class="name"><code>webName</code></td>
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
<td class="type">
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
<span class="param-type">Object</span>
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
</td>
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
<td class="attributes">
|
|
498
|
+
|
|
499
|
+
<optional><br>
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
</td>
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
<td class="default">
|
|
510
|
+
|
|
511
|
+
<code>{}</code>
|
|
512
|
+
|
|
513
|
+
</td>
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
<td class="description last"><p>輸入站台名稱物件,至少包含語系eng與cht鍵的名稱,預設{}</p></td>
|
|
517
|
+
</tr>
|
|
518
|
+
|
|
519
|
+
|
|
454
520
|
</tbody>
|
|
455
521
|
</table>
|
|
456
522
|
|
|
@@ -538,7 +604,7 @@
|
|
|
538
604
|
<br class="clear">
|
|
539
605
|
|
|
540
606
|
<footer>
|
|
541
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022
|
|
607
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 13:49:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
542
608
|
</footer>
|
|
543
609
|
|
|
544
610
|
<script>prettyPrint();</script>
|
package/docs/WWebApi.mjs.html
CHANGED
|
@@ -50,10 +50,10 @@ import j2o from 'wsemi/src/j2o.mjs'
|
|
|
50
50
|
import iseobj from 'wsemi/src/iseobj'
|
|
51
51
|
import isestr from 'wsemi/src/isestr'
|
|
52
52
|
import ispint from 'wsemi/src/ispint'
|
|
53
|
+
import isfun from 'wsemi/src/isfun'
|
|
53
54
|
import fsIsFolder from 'wsemi/src/fsIsFolder'
|
|
54
55
|
import cint from 'wsemi/src/cint'
|
|
55
56
|
import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
|
|
56
|
-
import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs'
|
|
57
57
|
import ds from '../src/schema/index.mjs'
|
|
58
58
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
59
59
|
|
|
@@ -63,62 +63,79 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
63
63
|
*
|
|
64
64
|
* @class
|
|
65
65
|
* @param {Object} [opt={}] 輸入設定物件,預設{}
|
|
66
|
-
* @param {String}
|
|
67
|
-
* @param {String}
|
|
68
|
-
* @param {
|
|
66
|
+
* @param {String} opt.url 輸入資料庫連線字串,例如'mongodb://sername:password@$127.0.0.1:27017'
|
|
67
|
+
* @param {String} opt.db 輸入資料庫名稱字串
|
|
68
|
+
* @param {Function} opt.WOrm 輸入資料庫ORM函數
|
|
69
|
+
* @param {Integer} [opt.serverPort=11005] 輸入伺服器通訊port,預設11005
|
|
69
70
|
* @param {Function} [opt.getUserById=null] 輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null
|
|
70
71
|
* @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
|
|
71
72
|
* @param {Boolean} [opt.bExcludeWhenNotAdmin=true] 輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設true
|
|
73
|
+
* @param {Object} [opt.webName={}] 輸入站台名稱物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
72
74
|
* @returns {Object} 回傳物件,其內server為hapi伺服器實體,wsrv為w-converhp的伺服器事件物件,wsds為w-serv-webdata的伺服器事件物件,可監聽error事件
|
|
73
75
|
* @example
|
|
74
76
|
*
|
|
75
77
|
|
|
76
78
|
*
|
|
77
79
|
*/
|
|
78
|
-
async function WWebApi(
|
|
80
|
+
async function WWebApi(url, db, WOrm, opt = {}) {
|
|
79
81
|
|
|
80
82
|
|
|
81
|
-
//url
|
|
82
|
-
let url = get(st, 'url')
|
|
83
|
+
//check url
|
|
83
84
|
if (!isestr(url)) {
|
|
84
85
|
console.log('invalid url', url)
|
|
85
86
|
throw new Error('invalid url')
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
|
|
89
|
-
//db
|
|
90
|
-
let db = get(st, 'db')
|
|
90
|
+
//check db
|
|
91
91
|
if (!isestr(db)) {
|
|
92
92
|
console.log('invalid db', db)
|
|
93
93
|
throw new Error('invalid db')
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
//check WOrm
|
|
98
|
+
if (!isfun(WOrm)) {
|
|
99
|
+
console.log('invalid WOrm', WOrm)
|
|
100
|
+
throw new Error('invalid WOrm')
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
97
104
|
//serverPort
|
|
98
|
-
let serverPort = get(
|
|
105
|
+
let serverPort = get(opt, 'serverPort')
|
|
99
106
|
if (!ispint(serverPort)) {
|
|
100
|
-
|
|
101
|
-
throw new Error('invalid serverPort')
|
|
107
|
+
serverPort = 11005
|
|
102
108
|
}
|
|
103
109
|
serverPort = cint(serverPort)
|
|
104
110
|
|
|
105
111
|
|
|
112
|
+
//getUserById
|
|
113
|
+
let getUserById = get(opt, 'getUserById', null)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
//bCheckUser
|
|
117
|
+
let bCheckUser = get(opt, 'bCheckUser', false)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
//bExcludeWhenNotAdmin
|
|
121
|
+
let bExcludeWhenNotAdmin = get(opt, 'bExcludeWhenNotAdmin', false)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
//webName
|
|
125
|
+
let webName = get(opt, 'webName', {})
|
|
126
|
+
|
|
127
|
+
|
|
106
128
|
//WServOrm
|
|
107
|
-
let
|
|
108
|
-
// url: `mongodb://${st.dbUsername}:${st.dbPassword}@${st.dbIP}:${st.dbPort}`,
|
|
109
|
-
// db: st.dbName,
|
|
110
|
-
// getUserById: null,
|
|
111
|
-
// bCheckUser: false,
|
|
112
|
-
// bExcludeWhenNotAdmin: false,
|
|
129
|
+
let optWServOrm = {
|
|
113
130
|
url,
|
|
114
131
|
db,
|
|
115
|
-
getUserById
|
|
116
|
-
bCheckUser
|
|
117
|
-
bExcludeWhenNotAdmin
|
|
132
|
+
getUserById,
|
|
133
|
+
bCheckUser,
|
|
134
|
+
bExcludeWhenNotAdmin,
|
|
118
135
|
}
|
|
119
136
|
let wp = {}
|
|
120
137
|
try {
|
|
121
|
-
wp = WServOrm(ds, WOrm,
|
|
138
|
+
wp = WServOrm(ds, WOrm, optWServOrm)
|
|
122
139
|
}
|
|
123
140
|
catch (err) {
|
|
124
141
|
console.log(err)
|
|
@@ -129,7 +146,7 @@ async function WWebApi(st = {}) {
|
|
|
129
146
|
//getWebInfor
|
|
130
147
|
let getWebInfor = (userId) => {
|
|
131
148
|
return {
|
|
132
|
-
webName
|
|
149
|
+
webName,
|
|
133
150
|
}
|
|
134
151
|
}
|
|
135
152
|
|
|
@@ -281,7 +298,7 @@ async function WWebApi(st = {}) {
|
|
|
281
298
|
|
|
282
299
|
//WServHapiServer
|
|
283
300
|
let wshs = WServHapiServer({
|
|
284
|
-
port:
|
|
301
|
+
port: opt.serverPort,
|
|
285
302
|
pathStaticFiles,
|
|
286
303
|
apis,
|
|
287
304
|
getUserIDFromToken: async (token) => { //可使用async或sync函數
|
|
@@ -322,7 +339,7 @@ export default WWebApi
|
|
|
322
339
|
<br class="clear">
|
|
323
340
|
|
|
324
341
|
<footer>
|
|
325
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022
|
|
342
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 13:49:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
326
343
|
</footer>
|
|
327
344
|
|
|
328
345
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
<br class="clear">
|
|
69
69
|
|
|
70
70
|
<footer>
|
|
71
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022
|
|
71
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 13:49:57 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "w-web-api",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "dist/w-web-api.umd.js",
|
|
5
|
-
"dependencies": {
|
|
6
|
-
"@mdi/js": "^6.6.96",
|
|
7
|
-
"lodash": "^4.17.21",
|
|
8
|
-
"showdown": "^2.0.3",
|
|
9
|
-
"w-component-vue": "^2.2.6",
|
|
10
|
-
"w-data-collector": "^1.0.13",
|
|
11
|
-
"w-orm-mongodb": "^1.1.26",
|
|
12
|
-
"w-serv-hapi": "^1.0.5",
|
|
13
|
-
"w-serv-orm": "^1.0.0",
|
|
14
|
-
"wsemi": "^1.6.55"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"eslint": "^7.26.0",
|
|
18
|
-
"eslint-config-standard": "^16.0.2",
|
|
19
|
-
"eslint-friendly-formatter": "^4.0.1",
|
|
20
|
-
"eslint-loader": "^4.0.2",
|
|
21
|
-
"eslint-plugin-import": "^2.22.1",
|
|
22
|
-
"eslint-plugin-node": "^11.1.0",
|
|
23
|
-
"eslint-plugin-promise": "^5.1.0",
|
|
24
|
-
"eslint-plugin-standard": "^4.1.0",
|
|
25
|
-
"eslint-plugin-vue": "^7.9.0",
|
|
26
|
-
"@vue/cli-plugin-babel": "^4.5.13",
|
|
27
|
-
"@vue/cli-plugin-eslint": "^4.5.13",
|
|
28
|
-
"@vue/cli-service": "^4.5.13",
|
|
29
|
-
"cheerio": "^1.0.0-rc.10",
|
|
30
|
-
"sass": "^1.34.0",
|
|
31
|
-
"sass-loader": "^10.1.1",
|
|
32
|
-
"vue": "^2.6.14",
|
|
33
|
-
"vuex": "^3.6.2",
|
|
34
|
-
"vue-cli-plugin-vuetify": "^2.4.8",
|
|
35
|
-
"vuetify": "^2.6.4",
|
|
36
|
-
"vuetify-loader": "^1.7.3",
|
|
37
|
-
"w-package-tools": "^1.0.65"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"serve": "vue-cli-service serve",
|
|
41
|
-
"build": "vue-cli-service build",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "w-web-api",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"main": "dist/w-web-api.umd.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@mdi/js": "^6.6.96",
|
|
7
|
+
"lodash": "^4.17.21",
|
|
8
|
+
"showdown": "^2.0.3",
|
|
9
|
+
"w-component-vue": "^2.2.6",
|
|
10
|
+
"w-data-collector": "^1.0.13",
|
|
11
|
+
"w-orm-mongodb": "^1.1.26",
|
|
12
|
+
"w-serv-hapi": "^1.0.5",
|
|
13
|
+
"w-serv-orm": "^1.0.0",
|
|
14
|
+
"wsemi": "^1.6.55"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"eslint": "^7.26.0",
|
|
18
|
+
"eslint-config-standard": "^16.0.2",
|
|
19
|
+
"eslint-friendly-formatter": "^4.0.1",
|
|
20
|
+
"eslint-loader": "^4.0.2",
|
|
21
|
+
"eslint-plugin-import": "^2.22.1",
|
|
22
|
+
"eslint-plugin-node": "^11.1.0",
|
|
23
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
24
|
+
"eslint-plugin-standard": "^4.1.0",
|
|
25
|
+
"eslint-plugin-vue": "^7.9.0",
|
|
26
|
+
"@vue/cli-plugin-babel": "^4.5.13",
|
|
27
|
+
"@vue/cli-plugin-eslint": "^4.5.13",
|
|
28
|
+
"@vue/cli-service": "^4.5.13",
|
|
29
|
+
"cheerio": "^1.0.0-rc.10",
|
|
30
|
+
"sass": "^1.34.0",
|
|
31
|
+
"sass-loader": "^10.1.1",
|
|
32
|
+
"vue": "^2.6.14",
|
|
33
|
+
"vuex": "^3.6.2",
|
|
34
|
+
"vue-cli-plugin-vuetify": "^2.4.8",
|
|
35
|
+
"vuetify": "^2.6.4",
|
|
36
|
+
"vuetify-loader": "^1.7.3",
|
|
37
|
+
"w-package-tools": "^1.0.65"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"serve": "vue-cli-service serve",
|
|
41
|
+
"build": "vue-cli-service build",
|
|
42
|
+
"test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",
|
|
43
|
+
"lint": "vue-cli-service lint",
|
|
44
|
+
"deploy": "gh-pages -d docs"
|
|
45
|
+
},
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"root": true,
|
|
48
|
+
"env": {
|
|
49
|
+
"node": true
|
|
50
|
+
},
|
|
51
|
+
"extends": [
|
|
52
|
+
"plugin:vue/essential",
|
|
53
|
+
"eslint:recommended"
|
|
54
|
+
],
|
|
55
|
+
"rules": {},
|
|
56
|
+
"parserOptions": {
|
|
57
|
+
"parser": "babel-eslint"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"browserslist": [
|
|
61
|
+
"> 1%",
|
|
62
|
+
"last 2 versions"
|
|
63
|
+
],
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "https://github.com/yuda-lyu/w-web-api"
|
|
67
|
+
},
|
|
68
|
+
"keywords": [
|
|
69
|
+
"lodash",
|
|
70
|
+
"color",
|
|
71
|
+
"crypto",
|
|
72
|
+
"fuzzy",
|
|
73
|
+
"xss",
|
|
74
|
+
"xlsx",
|
|
75
|
+
"tool",
|
|
76
|
+
"package ",
|
|
77
|
+
"browser",
|
|
78
|
+
"developer"
|
|
79
|
+
],
|
|
80
|
+
"author": "yuda-lyu(semisphere)",
|
|
81
|
+
"license": "MIT"
|
|
82
|
+
}
|