w-web-api 1.0.6 → 1.0.7
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/README.md +1 -1
- package/dist/index.html +1 -1
- package/dist/js/{app.584c7442.js → app.462646b9.js} +1 -1
- package/dist/js/{app.584c7442.js.map → app.462646b9.js.map} +1 -1
- package/dist/js/{chunk-vendors.35dfbb6b.js → chunk-vendors.f69911fd.js} +1 -1
- package/dist/js/{chunk-vendors.35dfbb6b.js.map → chunk-vendors.f69911fd.js.map} +1 -1
- package/dist/w-web-api.umd.js +2 -2
- package/dist/w-web-api.umd.js.map +1 -1
- package/docs/WWebApi.html +38 -38
- package/docs/WWebApi.mjs.html +19 -21
- package/docs/index.html +1 -1
- package/{server/getSettings.mjs → g.getSettings.mjs} +0 -0
- package/{server/mDb.mjs → g.mDb.mjs} +3 -3
- package/{server/mInitialTestData.mjs → g.mInitialTestData.mjs} +3 -3
- package/{server/mOrm.mjs → g.mOrm.mjs} +7 -5
- package/package.json +8 -7
- package/server/WWebApi.mjs +18 -20
- package/server/provideApis.mjs +70 -0
- package/srv.mjs +2 -2
- package/tableTags-web-api.json +1 -1
package/docs/WWebApi.html
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
<h4 class="name" id="WWebApi"><span class="type-signature">(async) </span>new WWebApi<span class="signature">(opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
|
62
|
+
<h4 class="name" id="WWebApi"><span class="type-signature">(async) </span>new WWebApi<span class="signature">(WOrm, url, db, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
|
|
125
125
|
<h5>Example</h5>
|
|
126
126
|
|
|
127
|
-
<pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
|
|
128
127
|
getUserById: null,
|
|
129
128
|
bCheckUser: false,
|
|
130
129
|
bExcludeWhenNotAdmin: false,
|
|
131
130
|
serverPort: 11005,
|
|
132
131
|
webName: {
|
|
133
132
|
'eng': 'API Service',
|
|
134
133
|
'cht': 'API管理系統'
|
|
135
134
|
},
|
|
136
135
|
.catch((err) => {
|
|
137
136
|
console.log(err)
|
|
138
137
|
})</code></pre>
|
|
138
|
+
<pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
|
|
139
139
|
getUserById: null,
|
|
140
140
|
bCheckUser: false,
|
|
141
141
|
bExcludeWhenNotAdmin: false,
|
|
142
142
|
serverPort: 11005,
|
|
143
143
|
webName: {
|
|
144
144
|
'eng': 'API Service',
|
|
145
145
|
'cht': 'API管理系統'
|
|
146
146
|
},
|
|
147
147
|
.catch((err) => {
|
|
148
148
|
console.log(err)
|
|
149
149
|
})</code></pre>
|
|
150
150
|
|
|
151
151
|
|
|
152
152
|
|
|
@@ -158,13 +158,13 @@
|
|
|
158
158
|
|
|
159
159
|
<tr>
|
|
160
160
|
|
|
161
|
-
<td class="name"><code>
|
|
161
|
+
<td class="name"><code>WOrm</code></td>
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
<td class="type">
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
<span class="param-type">
|
|
167
|
+
<span class="param-type">function</span>
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
|
|
@@ -173,8 +173,6 @@
|
|
|
173
173
|
|
|
174
174
|
<td class="attributes">
|
|
175
175
|
|
|
176
|
-
<optional><br>
|
|
177
|
-
|
|
178
176
|
|
|
179
177
|
|
|
180
178
|
|
|
@@ -185,37 +183,12 @@
|
|
|
185
183
|
|
|
186
184
|
<td class="default">
|
|
187
185
|
|
|
188
|
-
<code>{}</code>
|
|
189
|
-
|
|
190
186
|
</td>
|
|
191
187
|
|
|
192
188
|
|
|
193
|
-
<td class="description last"><p
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<table class="params">
|
|
198
|
-
<thead>
|
|
199
|
-
<tr>
|
|
200
|
-
|
|
201
|
-
<th>Name</th>
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<th>Type</th>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
<th>Attributes</th>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
<th>Default</th>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
<th class="last">Description</th>
|
|
215
|
-
</tr>
|
|
216
|
-
</thead>
|
|
189
|
+
<td class="description last"><p>輸入資料庫ORM函數</p></td>
|
|
190
|
+
</tr>
|
|
217
191
|
|
|
218
|
-
<tbody>
|
|
219
192
|
|
|
220
193
|
|
|
221
194
|
<tr>
|
|
@@ -290,13 +263,13 @@
|
|
|
290
263
|
|
|
291
264
|
<tr>
|
|
292
265
|
|
|
293
|
-
<td class="name"><code>
|
|
266
|
+
<td class="name"><code>opt</code></td>
|
|
294
267
|
|
|
295
268
|
|
|
296
269
|
<td class="type">
|
|
297
270
|
|
|
298
271
|
|
|
299
|
-
<span class="param-type">
|
|
272
|
+
<span class="param-type">Object</span>
|
|
300
273
|
|
|
301
274
|
|
|
302
275
|
|
|
@@ -305,6 +278,8 @@
|
|
|
305
278
|
|
|
306
279
|
<td class="attributes">
|
|
307
280
|
|
|
281
|
+
<optional><br>
|
|
282
|
+
|
|
308
283
|
|
|
309
284
|
|
|
310
285
|
|
|
@@ -315,12 +290,37 @@
|
|
|
315
290
|
|
|
316
291
|
<td class="default">
|
|
317
292
|
|
|
293
|
+
<code>{}</code>
|
|
294
|
+
|
|
318
295
|
</td>
|
|
319
296
|
|
|
320
297
|
|
|
321
|
-
<td class="description last"><p
|
|
322
|
-
|
|
298
|
+
<td class="description last"><p>輸入設定物件,預設{}</p>
|
|
299
|
+
<h6>Properties</h6>
|
|
300
|
+
|
|
323
301
|
|
|
302
|
+
<table class="params">
|
|
303
|
+
<thead>
|
|
304
|
+
<tr>
|
|
305
|
+
|
|
306
|
+
<th>Name</th>
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
<th>Type</th>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
<th>Attributes</th>
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
<th>Default</th>
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
<th class="last">Description</th>
|
|
320
|
+
</tr>
|
|
321
|
+
</thead>
|
|
322
|
+
|
|
323
|
+
<tbody>
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
<tr>
|
|
@@ -604,7 +604,7 @@
|
|
|
604
604
|
<br class="clear">
|
|
605
605
|
|
|
606
606
|
<footer>
|
|
607
|
-
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 16:47:26 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
608
608
|
</footer>
|
|
609
609
|
|
|
610
610
|
<script>prettyPrint();</script>
|
package/docs/WWebApi.mjs.html
CHANGED
|
@@ -62,10 +62,10 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
62
62
|
* 基於hapi之API伺服器
|
|
63
63
|
*
|
|
64
64
|
* @class
|
|
65
|
+
* @param {Function} WOrm 輸入資料庫ORM函數
|
|
66
|
+
* @param {String} url 輸入資料庫連線字串,例如'mongodb://sername:password@$127.0.0.1:27017'
|
|
67
|
+
* @param {String} db 輸入資料庫名稱字串
|
|
65
68
|
* @param {Object} [opt={}] 輸入設定物件,預設{}
|
|
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
69
|
* @param {Integer} [opt.serverPort=11005] 輸入伺服器通訊port,預設11005
|
|
70
70
|
* @param {Function} [opt.getUserById=null] 輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null
|
|
71
71
|
* @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
|
|
@@ -99,13 +99,20 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
99
99
|
* }
|
|
100
100
|
*
|
|
101
101
|
* //WWebApi
|
|
102
|
-
* WWebApi(url, db,
|
|
102
|
+
* WWebApi(WOrm, url, db, opt)
|
|
103
103
|
* .catch((err) => {
|
|
104
104
|
* console.log(err)
|
|
105
105
|
* })
|
|
106
106
|
*
|
|
107
107
|
*/
|
|
108
|
-
async function WWebApi(url, db,
|
|
108
|
+
async function WWebApi(WOrm, url, db, opt = {}) {
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
//check WOrm
|
|
112
|
+
if (!isfun(WOrm)) {
|
|
113
|
+
console.log('invalid WOrm', WOrm)
|
|
114
|
+
throw new Error('invalid WOrm')
|
|
115
|
+
}
|
|
109
116
|
|
|
110
117
|
|
|
111
118
|
//check url
|
|
@@ -122,13 +129,6 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
|
|
125
|
-
//check WOrm
|
|
126
|
-
if (!isfun(WOrm)) {
|
|
127
|
-
console.log('invalid WOrm', WOrm)
|
|
128
|
-
throw new Error('invalid WOrm')
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
132
|
//serverPort
|
|
133
133
|
let serverPort = get(opt, 'serverPort')
|
|
134
134
|
if (!ispint(serverPort)) {
|
|
@@ -137,14 +137,14 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
137
137
|
serverPort = cint(serverPort)
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
//getUserById
|
|
141
|
-
let getUserById = get(opt, 'getUserById', null)
|
|
142
|
-
|
|
143
|
-
|
|
144
140
|
//bCheckUser
|
|
145
141
|
let bCheckUser = get(opt, 'bCheckUser', false)
|
|
146
142
|
|
|
147
143
|
|
|
144
|
+
//getUserById
|
|
145
|
+
let getUserById = get(opt, 'getUserById', null)
|
|
146
|
+
|
|
147
|
+
|
|
148
148
|
//bExcludeWhenNotAdmin
|
|
149
149
|
let bExcludeWhenNotAdmin = get(opt, 'bExcludeWhenNotAdmin', false)
|
|
150
150
|
|
|
@@ -155,15 +155,13 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
155
155
|
|
|
156
156
|
//WServOrm
|
|
157
157
|
let optWServOrm = {
|
|
158
|
-
url,
|
|
159
|
-
db,
|
|
160
|
-
getUserById,
|
|
161
158
|
bCheckUser,
|
|
159
|
+
getUserById,
|
|
162
160
|
bExcludeWhenNotAdmin,
|
|
163
161
|
}
|
|
164
162
|
let wp = {}
|
|
165
163
|
try {
|
|
166
|
-
wp = WServOrm(ds, WOrm, optWServOrm)
|
|
164
|
+
wp = WServOrm(ds, WOrm, url, db, optWServOrm)
|
|
167
165
|
}
|
|
168
166
|
catch (err) {
|
|
169
167
|
console.log(err)
|
|
@@ -369,7 +367,7 @@ export default WWebApi
|
|
|
369
367
|
<br class="clear">
|
|
370
368
|
|
|
371
369
|
<footer>
|
|
372
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022
|
|
370
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 16:47:26 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
373
371
|
</footer>
|
|
374
372
|
|
|
375
373
|
<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 16:47:26 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
|
File without changes
|
|
@@ -3,8 +3,8 @@ import fs from 'fs'
|
|
|
3
3
|
// import _ from 'lodash'
|
|
4
4
|
import w from 'wsemi'
|
|
5
5
|
import br from 'w-serv-orm/src/getDbBackupAndRecover.mjs'
|
|
6
|
-
import { woItems } from './mOrm.mjs'
|
|
7
|
-
// import { genModels } from './mOrmGenModels.mjs'
|
|
6
|
+
import { woItems } from './g.mOrm.mjs'
|
|
7
|
+
// import { genModels } from './g.mOrmGenModels.mjs'
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
//mOrmGenModels.mjs
|
|
@@ -73,4 +73,4 @@ function recover() {
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
//備份資料重與由備份資料重建資料庫
|
|
76
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
76
|
+
//node --experimental-modules --es-module-specifier-resolution=node g.mDb.mjs
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// import fs from 'fs'
|
|
3
3
|
// import _ from 'lodash'
|
|
4
4
|
import w from 'wsemi'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import ds from './src/schema/index.mjs'
|
|
6
|
+
import { woItems } from './g.mOrm.mjs'
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
async function initialTestData() {
|
|
@@ -37,4 +37,4 @@ initialTestData()
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
//刪除舊檔與重建測試資料庫
|
|
40
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
40
|
+
//node --experimental-modules --es-module-specifier-resolution=node g.mInitialTestData.mjs
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs'
|
|
2
|
-
import ds from '../src/schema/index.mjs'
|
|
3
|
-
import getSettings from './getSettings.mjs'
|
|
4
2
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
3
|
+
import ds from './src/schema/index.mjs'
|
|
4
|
+
import getSettings from './g.getSettings.mjs'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
//getSettings
|
|
8
8
|
let st = getSettings()
|
|
9
9
|
|
|
10
|
+
//url, db
|
|
11
|
+
let url = `mongodb://${st.dbUsername}:${st.dbPassword}@${st.dbIP}:${st.dbPort}`
|
|
12
|
+
let db = st.dbName
|
|
13
|
+
|
|
10
14
|
//WServOrm
|
|
11
15
|
let opt = {
|
|
12
|
-
url: `mongodb://${st.dbUsername}:${st.dbPassword}@${st.dbIP}:${st.dbPort}`,
|
|
13
|
-
db: st.dbName,
|
|
14
16
|
getUserById: null,
|
|
15
17
|
bCheckUser: false,
|
|
16
18
|
bExcludeWhenNotAdmin: false,
|
|
17
19
|
}
|
|
18
|
-
let r = WServOrm(ds, WOrm, opt)
|
|
20
|
+
let r = WServOrm(ds, WOrm, url, db, opt)
|
|
19
21
|
let { woItems, procOrm } = r
|
|
20
22
|
|
|
21
23
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-web-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"main": "dist/w-web-api.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@mdi/js": "^6.6.96",
|
|
7
|
+
"axios": "^0.26.1",
|
|
7
8
|
"lodash": "^4.17.21",
|
|
8
9
|
"showdown": "^2.0.3",
|
|
9
10
|
"w-component-vue": "^2.2.6",
|
|
10
11
|
"w-data-collector": "^1.0.13",
|
|
11
12
|
"w-serv-hapi": "^1.0.6",
|
|
12
|
-
"w-serv-orm": "^1.0.
|
|
13
|
+
"w-serv-orm": "^1.0.1",
|
|
13
14
|
"wsemi": "^1.6.55"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
17
|
+
"@vue/cli-plugin-babel": "^4.5.13",
|
|
18
|
+
"@vue/cli-plugin-eslint": "^4.5.13",
|
|
19
|
+
"@vue/cli-service": "^4.5.13",
|
|
20
|
+
"cheerio": "^1.0.0-rc.10",
|
|
16
21
|
"eslint": "^7.26.0",
|
|
17
22
|
"eslint-config-standard": "^16.0.2",
|
|
18
23
|
"eslint-friendly-formatter": "^4.0.1",
|
|
@@ -22,17 +27,13 @@
|
|
|
22
27
|
"eslint-plugin-promise": "^5.1.0",
|
|
23
28
|
"eslint-plugin-standard": "^4.1.0",
|
|
24
29
|
"eslint-plugin-vue": "^7.9.0",
|
|
25
|
-
"@vue/cli-plugin-babel": "^4.5.13",
|
|
26
|
-
"@vue/cli-plugin-eslint": "^4.5.13",
|
|
27
|
-
"@vue/cli-service": "^4.5.13",
|
|
28
|
-
"cheerio": "^1.0.0-rc.10",
|
|
29
30
|
"sass": "^1.34.0",
|
|
30
31
|
"sass-loader": "^10.1.1",
|
|
31
32
|
"vue": "^2.6.14",
|
|
32
|
-
"vuex": "^3.6.2",
|
|
33
33
|
"vue-cli-plugin-vuetify": "^2.4.8",
|
|
34
34
|
"vuetify": "^2.6.4",
|
|
35
35
|
"vuetify-loader": "^1.7.3",
|
|
36
|
+
"vuex": "^3.6.2",
|
|
36
37
|
"w-orm-mongodb": "^1.1.26",
|
|
37
38
|
"w-package-tools": "^1.0.65"
|
|
38
39
|
},
|
package/server/WWebApi.mjs
CHANGED
|
@@ -18,10 +18,10 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
18
18
|
* 基於hapi之API伺服器
|
|
19
19
|
*
|
|
20
20
|
* @class
|
|
21
|
+
* @param {Function} WOrm 輸入資料庫ORM函數
|
|
22
|
+
* @param {String} url 輸入資料庫連線字串,例如'mongodb://sername:password@$127.0.0.1:27017'
|
|
23
|
+
* @param {String} db 輸入資料庫名稱字串
|
|
21
24
|
* @param {Object} [opt={}] 輸入設定物件,預設{}
|
|
22
|
-
* @param {String} opt.url 輸入資料庫連線字串,例如'mongodb://sername:password@$127.0.0.1:27017'
|
|
23
|
-
* @param {String} opt.db 輸入資料庫名稱字串
|
|
24
|
-
* @param {Function} opt.WOrm 輸入資料庫ORM函數
|
|
25
25
|
* @param {Integer} [opt.serverPort=11005] 輸入伺服器通訊port,預設11005
|
|
26
26
|
* @param {Function} [opt.getUserById=null] 輸入當bCheckUser=true時依照使用者ID取得使用者資訊物件函數,預設null
|
|
27
27
|
* @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
|
|
@@ -55,13 +55,20 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
55
55
|
* }
|
|
56
56
|
*
|
|
57
57
|
* //WWebApi
|
|
58
|
-
* WWebApi(url, db,
|
|
58
|
+
* WWebApi(WOrm, url, db, opt)
|
|
59
59
|
* .catch((err) => {
|
|
60
60
|
* console.log(err)
|
|
61
61
|
* })
|
|
62
62
|
*
|
|
63
63
|
*/
|
|
64
|
-
async function WWebApi(url, db,
|
|
64
|
+
async function WWebApi(WOrm, url, db, opt = {}) {
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//check WOrm
|
|
68
|
+
if (!isfun(WOrm)) {
|
|
69
|
+
console.log('invalid WOrm', WOrm)
|
|
70
|
+
throw new Error('invalid WOrm')
|
|
71
|
+
}
|
|
65
72
|
|
|
66
73
|
|
|
67
74
|
//check url
|
|
@@ -78,13 +85,6 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
|
|
81
|
-
//check WOrm
|
|
82
|
-
if (!isfun(WOrm)) {
|
|
83
|
-
console.log('invalid WOrm', WOrm)
|
|
84
|
-
throw new Error('invalid WOrm')
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
88
|
//serverPort
|
|
89
89
|
let serverPort = get(opt, 'serverPort')
|
|
90
90
|
if (!ispint(serverPort)) {
|
|
@@ -93,14 +93,14 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
93
93
|
serverPort = cint(serverPort)
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
//getUserById
|
|
97
|
-
let getUserById = get(opt, 'getUserById', null)
|
|
98
|
-
|
|
99
|
-
|
|
100
96
|
//bCheckUser
|
|
101
97
|
let bCheckUser = get(opt, 'bCheckUser', false)
|
|
102
98
|
|
|
103
99
|
|
|
100
|
+
//getUserById
|
|
101
|
+
let getUserById = get(opt, 'getUserById', null)
|
|
102
|
+
|
|
103
|
+
|
|
104
104
|
//bExcludeWhenNotAdmin
|
|
105
105
|
let bExcludeWhenNotAdmin = get(opt, 'bExcludeWhenNotAdmin', false)
|
|
106
106
|
|
|
@@ -111,15 +111,13 @@ async function WWebApi(url, db, WOrm, opt = {}) {
|
|
|
111
111
|
|
|
112
112
|
//WServOrm
|
|
113
113
|
let optWServOrm = {
|
|
114
|
-
url,
|
|
115
|
-
db,
|
|
116
|
-
getUserById,
|
|
117
114
|
bCheckUser,
|
|
115
|
+
getUserById,
|
|
118
116
|
bExcludeWhenNotAdmin,
|
|
119
117
|
}
|
|
120
118
|
let wp = {}
|
|
121
119
|
try {
|
|
122
|
-
wp = WServOrm(ds, WOrm, optWServOrm)
|
|
120
|
+
wp = WServOrm(ds, WOrm, url, db, optWServOrm)
|
|
123
121
|
}
|
|
124
122
|
catch (err) {
|
|
125
123
|
console.log(err)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import map from 'lodash/map'
|
|
3
|
+
import ltdtpick from 'wsemi/src/ltdtpick.mjs'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async function provideApis(url, levels, apis) {
|
|
7
|
+
//url: 指API伺服器提供的接入網址, 例如 http://localhost:11005/replaceAPIsByLevels
|
|
8
|
+
|
|
9
|
+
//ks
|
|
10
|
+
let ks = [
|
|
11
|
+
'id', //'id-for-apis-pets-guineapigs-1'
|
|
12
|
+
'name', //'取得天竺鼠清單資訊'
|
|
13
|
+
'description', //'取得天竺鼠清單資訊'
|
|
14
|
+
'url', //指api網址, 例如 http://localhost:11005/getDogsList
|
|
15
|
+
'method', //'get'
|
|
16
|
+
'version', //'v1'
|
|
17
|
+
'levels', //'寵物.天竺鼠'
|
|
18
|
+
'keywords', //'pets;guineapigs'
|
|
19
|
+
'state', //'ok'
|
|
20
|
+
'creator', //'pets-system'
|
|
21
|
+
'dataSource', //'pets-data'
|
|
22
|
+
'mdInputParams', //輸入方式說明, markdown格式
|
|
23
|
+
'outputExample', //輸出範例數據, json格式
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
//ltdtpick
|
|
27
|
+
apis = ltdtpick(apis, ks)
|
|
28
|
+
|
|
29
|
+
//update levels
|
|
30
|
+
apis = map(apis, (v) => {
|
|
31
|
+
v.levels = levels
|
|
32
|
+
return v
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
//rin
|
|
36
|
+
let rin = {
|
|
37
|
+
levels,
|
|
38
|
+
apis,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//axios
|
|
42
|
+
let rout
|
|
43
|
+
await axios({
|
|
44
|
+
method: 'post',
|
|
45
|
+
url,
|
|
46
|
+
headers: { 'Content-Type': 'application/json; charset=utf-8' },
|
|
47
|
+
data: rin,
|
|
48
|
+
})
|
|
49
|
+
.then((res) => {
|
|
50
|
+
// console.log(res)
|
|
51
|
+
rout = {
|
|
52
|
+
state: 'success',
|
|
53
|
+
msg: '成功傳輸API清單',
|
|
54
|
+
res,
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
// console.log(err)
|
|
59
|
+
rout = {
|
|
60
|
+
state: 'success',
|
|
61
|
+
msg: '無法傳輸API清單',
|
|
62
|
+
res: err,
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
return rout
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export default provideApis
|
package/srv.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
|
|
2
|
-
import getSettings from './server/getSettings.mjs'
|
|
3
2
|
import WWebApi from './server/WWebApi.mjs'
|
|
3
|
+
import getSettings from './g.getSettings.mjs'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
//st
|
|
@@ -24,7 +24,7 @@ let opt = {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
//WWebApi
|
|
27
|
-
WWebApi(url, db,
|
|
27
|
+
WWebApi(WOrm, url, db, opt)
|
|
28
28
|
.catch((err) => {
|
|
29
29
|
console.log(err)
|
|
30
30
|
})
|
package/tableTags-web-api.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"apis":"
|
|
1
|
+
{"apis":"dJSgfx"}
|