w-web-api 1.0.17 → 1.0.20
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 +6 -4
- package/dist/index.tmp +1 -0
- package/dist/js/app.3b169a5f.js +2 -0
- package/dist/js/app.3b169a5f.js.map +1 -0
- package/dist/js/{chunk-vendors.07b6a404.js → chunk-vendors.ec21cce7.js} +2 -2
- package/dist/js/chunk-vendors.ec21cce7.js.map +1 -0
- package/dist/w-web-api.umd.js +2 -2
- package/dist/w-web-api.umd.js.map +1 -1
- package/docs/WWebApi.html +121 -4
- package/docs/WWebApi.mjs.html +50 -18
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/server/WWebApi.mjs +48 -16
- package/srv.mjs +6 -4
- package/tableTags-web-api.json +1 -1
- package/toolg/genEntry.mjs +23 -0
- package/vue.config.js +1 -1
- package/dist/index.html +0 -1
- package/dist/js/app.3862cf85.js +0 -2
- package/dist/js/app.3862cf85.js.map +0 -1
- package/dist/js/chunk-vendors.07b6a404.js.map +0 -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"
|
|
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"> → {Object}</span></h4>
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
@@ -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#line78">line 78</a>
|
|
75
75
|
</li></ul></dd>
|
|
76
76
|
|
|
77
77
|
|
|
@@ -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
|
subfolder: '', //mpai
|
|
144
144
|
webName: {
|
|
145
145
|
'eng': 'API Service',
|
|
146
146
|
'cht': 'API管理系統'
|
|
147
147
|
},
|
|
148
148
|
console.log(err)
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
|
|
@@ -517,6 +517,123 @@
|
|
|
517
517
|
</tr>
|
|
518
518
|
|
|
519
519
|
|
|
520
|
+
|
|
521
|
+
<tr>
|
|
522
|
+
|
|
523
|
+
<td class="name"><code>webDescription</code></td>
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
<td class="type">
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
<span class="param-type">Object</span>
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
</td>
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
<td class="attributes">
|
|
537
|
+
|
|
538
|
+
<optional><br>
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
</td>
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
<td class="default">
|
|
549
|
+
|
|
550
|
+
<code>{}</code>
|
|
551
|
+
|
|
552
|
+
</td>
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
<td class="description last"><p>輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}</p></td>
|
|
556
|
+
</tr>
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
<tr>
|
|
561
|
+
|
|
562
|
+
<td class="name"><code>webLogo</code></td>
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
<td class="type">
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
<span class="param-type">String</span>
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
</td>
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
<td class="attributes">
|
|
576
|
+
|
|
577
|
+
<optional><br>
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
</td>
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
<td class="default">
|
|
588
|
+
|
|
589
|
+
<code>''</code>
|
|
590
|
+
|
|
591
|
+
</td>
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
<td class="description last"><p>輸入站台logo字串,採base64格式,預設''</p></td>
|
|
595
|
+
</tr>
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
<tr>
|
|
600
|
+
|
|
601
|
+
<td class="name"><code>subfolder</code></td>
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
<td class="type">
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
<span class="param-type">String</span>
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
</td>
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
<td class="attributes">
|
|
615
|
+
|
|
616
|
+
<optional><br>
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
</td>
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
<td class="default">
|
|
627
|
+
|
|
628
|
+
<code>''</code>
|
|
629
|
+
|
|
630
|
+
</td>
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
<td class="description last"><p>輸入站台所在子目錄字串,提供站台位於內網採反向代理進行服務時,故需支援位於子目錄情形,預設''</p></td>
|
|
634
|
+
</tr>
|
|
635
|
+
|
|
636
|
+
|
|
520
637
|
</tbody>
|
|
521
638
|
</table>
|
|
522
639
|
|
|
@@ -604,7 +721,7 @@
|
|
|
604
721
|
<br class="clear">
|
|
605
722
|
|
|
606
723
|
<footer>
|
|
607
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on
|
|
724
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed May 11 2022 17:56:39 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
608
725
|
</footer>
|
|
609
726
|
|
|
610
727
|
<script>prettyPrint();</script>
|
package/docs/WWebApi.mjs.html
CHANGED
|
@@ -42,21 +42,26 @@
|
|
|
42
42
|
|
|
43
43
|
<section>
|
|
44
44
|
<article>
|
|
45
|
-
<pre class="prettyprint source linenums"><code>import
|
|
45
|
+
<pre class="prettyprint source linenums"><code>import path from 'path'
|
|
46
|
+
import fs from 'fs'
|
|
47
|
+
import get from 'lodash/get'
|
|
46
48
|
// import map from 'lodash/map'
|
|
47
49
|
import each from 'lodash/each'
|
|
48
50
|
import keys from 'lodash/keys'
|
|
49
51
|
// import cloneDeep from 'lodash/cloneDeep'
|
|
50
52
|
import j2o from 'wsemi/src/j2o.mjs'
|
|
51
|
-
import iseobj from 'wsemi/src/iseobj'
|
|
52
|
-
import isestr from 'wsemi/src/isestr'
|
|
53
|
-
import ispint from 'wsemi/src/ispint'
|
|
54
|
-
import isfun from 'wsemi/src/isfun'
|
|
55
|
-
import cint from 'wsemi/src/cint'
|
|
56
|
-
import strleft from 'wsemi/src/strleft'
|
|
57
|
-
import strdelleft from 'wsemi/src/strdelleft'
|
|
58
|
-
import
|
|
59
|
-
import
|
|
53
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
54
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
55
|
+
import ispint from 'wsemi/src/ispint.mjs'
|
|
56
|
+
import isfun from 'wsemi/src/isfun.mjs'
|
|
57
|
+
import cint from 'wsemi/src/cint.mjs'
|
|
58
|
+
import strleft from 'wsemi/src/strleft.mjs'
|
|
59
|
+
import strdelleft from 'wsemi/src/strdelleft.mjs'
|
|
60
|
+
import strright from 'wsemi/src/strright.mjs'
|
|
61
|
+
import strdelright from 'wsemi/src/strdelright.mjs'
|
|
62
|
+
import b642str from 'wsemi/src/b642str.mjs'
|
|
63
|
+
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
64
|
+
import replace from 'wsemi/src/replace.mjs'
|
|
60
65
|
import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
|
|
61
66
|
import ds from '../src/schema/index.mjs'
|
|
62
67
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
@@ -75,6 +80,9 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
75
80
|
* @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
|
|
76
81
|
* @param {Boolean} [opt.bExcludeWhenNotAdmin=true] 輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設true
|
|
77
82
|
* @param {Object} [opt.webName={}] 輸入站台名稱物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
83
|
+
* @param {Object} [opt.webDescription={}] 輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
84
|
+
* @param {String} [opt.webLogo=''] 輸入站台logo字串,採base64格式,預設''
|
|
85
|
+
* @param {String} [opt.subfolder=''] 輸入站台所在子目錄字串,提供站台位於內網採反向代理進行服務時,故需支援位於子目錄情形,預設''
|
|
78
86
|
* @returns {Object} 回傳物件,其內server為hapi伺服器實體,wsrv為w-converhp的伺服器事件物件,wsds為w-serv-webdata的伺服器事件物件,可監聽error事件
|
|
79
87
|
* @example
|
|
80
88
|
*
|
|
@@ -94,6 +102,7 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
94
102
|
* bExcludeWhenNotAdmin: false,
|
|
95
103
|
*
|
|
96
104
|
* serverPort: 11005,
|
|
105
|
+
* subfolder: '', //mpai
|
|
97
106
|
*
|
|
98
107
|
* webName: {
|
|
99
108
|
* 'eng': 'API Service',
|
|
@@ -103,13 +112,14 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
103
112
|
* }
|
|
104
113
|
*
|
|
105
114
|
* //WWebApi
|
|
106
|
-
* WWebApi(WOrm, url, db, opt)
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
115
|
+
* let instWWebApi = WWebApi(WOrm, url, db, opt)
|
|
116
|
+
*
|
|
117
|
+
* instWWebApi.on('error', (err) => {
|
|
118
|
+
* console.log(err)
|
|
119
|
+
* })
|
|
110
120
|
*
|
|
111
121
|
*/
|
|
112
|
-
|
|
122
|
+
function WWebApi(WOrm, url, db, opt = {}) {
|
|
113
123
|
let instWServHapiServer = null
|
|
114
124
|
|
|
115
125
|
|
|
@@ -163,7 +173,19 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
163
173
|
|
|
164
174
|
|
|
165
175
|
//webLogo
|
|
166
|
-
let webLogo = get(opt, 'webLogo',
|
|
176
|
+
let webLogo = get(opt, 'webLogo', '')
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
//subfolder
|
|
180
|
+
let subfolder = get(opt, 'subfolder', '')
|
|
181
|
+
if (isestr(subfolder)) {
|
|
182
|
+
if (strright(subfolder, 1) === '/') { //右邊不需要給「/」
|
|
183
|
+
subfolder = strdelright(subfolder, 1)
|
|
184
|
+
}
|
|
185
|
+
if (strleft(subfolder, 1) !== '/') { //左邊需要給「/」
|
|
186
|
+
subfolder = `/${subfolder}`
|
|
187
|
+
}
|
|
188
|
+
}
|
|
167
189
|
|
|
168
190
|
|
|
169
191
|
//WServOrm
|
|
@@ -285,6 +307,16 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
285
307
|
// console.log('pathStaticFiles', pathStaticFiles)
|
|
286
308
|
|
|
287
309
|
|
|
310
|
+
//subfolder
|
|
311
|
+
let fnEntryIn = 'index.tmp'
|
|
312
|
+
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')
|
|
318
|
+
|
|
319
|
+
|
|
288
320
|
//apis
|
|
289
321
|
let apis = [
|
|
290
322
|
// {
|
|
@@ -363,7 +395,7 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
363
395
|
|
|
364
396
|
|
|
365
397
|
//WServHapiServer
|
|
366
|
-
instWServHapiServer = WServHapiServer({
|
|
398
|
+
instWServHapiServer = new WServHapiServer({
|
|
367
399
|
port: opt.serverPort,
|
|
368
400
|
pathStaticFiles,
|
|
369
401
|
apis,
|
|
@@ -406,7 +438,7 @@ export default WWebApi
|
|
|
406
438
|
<br class="clear">
|
|
407
439
|
|
|
408
440
|
<footer>
|
|
409
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on
|
|
441
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed May 11 2022 17:56:39 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
410
442
|
</footer>
|
|
411
443
|
|
|
412
444
|
<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
|
|
71
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed May 11 2022 17:56:39 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-web-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"main": "dist/w-web-api.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@mdi/js": "^6.6.96",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"showdown": "^2.0.3",
|
|
10
10
|
"w-component-vue": "^2.2.6",
|
|
11
11
|
"w-data-collector": "^1.0.13",
|
|
12
|
-
"w-serv-hapi": "^1.0.
|
|
12
|
+
"w-serv-hapi": "^1.0.9",
|
|
13
13
|
"w-serv-orm": "^1.0.2",
|
|
14
14
|
"wsemi": "^1.6.57"
|
|
15
15
|
},
|
package/server/WWebApi.mjs
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
1
3
|
import get from 'lodash/get'
|
|
2
4
|
// import map from 'lodash/map'
|
|
3
5
|
import each from 'lodash/each'
|
|
4
6
|
import keys from 'lodash/keys'
|
|
5
7
|
// import cloneDeep from 'lodash/cloneDeep'
|
|
6
8
|
import j2o from 'wsemi/src/j2o.mjs'
|
|
7
|
-
import iseobj from 'wsemi/src/iseobj'
|
|
8
|
-
import isestr from 'wsemi/src/isestr'
|
|
9
|
-
import ispint from 'wsemi/src/ispint'
|
|
10
|
-
import isfun from 'wsemi/src/isfun'
|
|
11
|
-
import cint from 'wsemi/src/cint'
|
|
12
|
-
import strleft from 'wsemi/src/strleft'
|
|
13
|
-
import strdelleft from 'wsemi/src/strdelleft'
|
|
14
|
-
import
|
|
15
|
-
import
|
|
9
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
10
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
11
|
+
import ispint from 'wsemi/src/ispint.mjs'
|
|
12
|
+
import isfun from 'wsemi/src/isfun.mjs'
|
|
13
|
+
import cint from 'wsemi/src/cint.mjs'
|
|
14
|
+
import strleft from 'wsemi/src/strleft.mjs'
|
|
15
|
+
import strdelleft from 'wsemi/src/strdelleft.mjs'
|
|
16
|
+
import strright from 'wsemi/src/strright.mjs'
|
|
17
|
+
import strdelright from 'wsemi/src/strdelright.mjs'
|
|
18
|
+
import b642str from 'wsemi/src/b642str.mjs'
|
|
19
|
+
import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
|
|
20
|
+
import replace from 'wsemi/src/replace.mjs'
|
|
16
21
|
import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
|
|
17
22
|
import ds from '../src/schema/index.mjs'
|
|
18
23
|
import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
@@ -31,6 +36,9 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
31
36
|
* @param {Boolean} [opt.bCheckUser=true] 輸入是否檢查使用者資訊布林值,預設true
|
|
32
37
|
* @param {Boolean} [opt.bExcludeWhenNotAdmin=true] 輸入使用ORM的select方法時是否自動刪除數據內isActive欄位之布林值,預設true
|
|
33
38
|
* @param {Object} [opt.webName={}] 輸入站台名稱物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
39
|
+
* @param {Object} [opt.webDescription={}] 輸入站台描述物件,至少包含語系eng與cht鍵的名稱,預設{}
|
|
40
|
+
* @param {String} [opt.webLogo=''] 輸入站台logo字串,採base64格式,預設''
|
|
41
|
+
* @param {String} [opt.subfolder=''] 輸入站台所在子目錄字串,提供站台位於內網採反向代理進行服務時,故需支援位於子目錄情形,預設''
|
|
34
42
|
* @returns {Object} 回傳物件,其內server為hapi伺服器實體,wsrv為w-converhp的伺服器事件物件,wsds為w-serv-webdata的伺服器事件物件,可監聽error事件
|
|
35
43
|
* @example
|
|
36
44
|
*
|
|
@@ -50,6 +58,7 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
50
58
|
* bExcludeWhenNotAdmin: false,
|
|
51
59
|
*
|
|
52
60
|
* serverPort: 11005,
|
|
61
|
+
* subfolder: '', //mpai
|
|
53
62
|
*
|
|
54
63
|
* webName: {
|
|
55
64
|
* 'eng': 'API Service',
|
|
@@ -59,13 +68,14 @@ import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
|
|
|
59
68
|
* }
|
|
60
69
|
*
|
|
61
70
|
* //WWebApi
|
|
62
|
-
* WWebApi(WOrm, url, db, opt)
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
71
|
+
* let instWWebApi = WWebApi(WOrm, url, db, opt)
|
|
72
|
+
*
|
|
73
|
+
* instWWebApi.on('error', (err) => {
|
|
74
|
+
* console.log(err)
|
|
75
|
+
* })
|
|
66
76
|
*
|
|
67
77
|
*/
|
|
68
|
-
|
|
78
|
+
function WWebApi(WOrm, url, db, opt = {}) {
|
|
69
79
|
let instWServHapiServer = null
|
|
70
80
|
|
|
71
81
|
|
|
@@ -119,7 +129,19 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
119
129
|
|
|
120
130
|
|
|
121
131
|
//webLogo
|
|
122
|
-
let webLogo = get(opt, 'webLogo',
|
|
132
|
+
let webLogo = get(opt, 'webLogo', '')
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
//subfolder
|
|
136
|
+
let subfolder = get(opt, 'subfolder', '')
|
|
137
|
+
if (isestr(subfolder)) {
|
|
138
|
+
if (strright(subfolder, 1) === '/') { //右邊不需要給「/」
|
|
139
|
+
subfolder = strdelright(subfolder, 1)
|
|
140
|
+
}
|
|
141
|
+
if (strleft(subfolder, 1) !== '/') { //左邊需要給「/」
|
|
142
|
+
subfolder = `/${subfolder}`
|
|
143
|
+
}
|
|
144
|
+
}
|
|
123
145
|
|
|
124
146
|
|
|
125
147
|
//WServOrm
|
|
@@ -241,6 +263,16 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
241
263
|
// console.log('pathStaticFiles', pathStaticFiles)
|
|
242
264
|
|
|
243
265
|
|
|
266
|
+
//subfolder
|
|
267
|
+
let fnEntryIn = 'index.tmp'
|
|
268
|
+
let fnEntryOut = 'index.html'
|
|
269
|
+
let fpEntryIn = path.resolve(pathStaticFiles, fnEntryIn)
|
|
270
|
+
let fpEntryOut = path.resolve(pathStaticFiles, fnEntryOut)
|
|
271
|
+
let c = fs.readFileSync(fpEntryIn, 'utf8')
|
|
272
|
+
c = replace(c, '{sfd}', subfolder)
|
|
273
|
+
fs.writeFileSync(fpEntryOut, c, 'utf8')
|
|
274
|
+
|
|
275
|
+
|
|
244
276
|
//apis
|
|
245
277
|
let apis = [
|
|
246
278
|
// {
|
|
@@ -319,7 +351,7 @@ async function WWebApi(WOrm, url, db, opt = {}) {
|
|
|
319
351
|
|
|
320
352
|
|
|
321
353
|
//WServHapiServer
|
|
322
|
-
instWServHapiServer = WServHapiServer({
|
|
354
|
+
instWServHapiServer = new WServHapiServer({
|
|
323
355
|
port: opt.serverPort,
|
|
324
356
|
pathStaticFiles,
|
|
325
357
|
apis,
|
package/srv.mjs
CHANGED
|
@@ -15,6 +15,7 @@ let opt = {
|
|
|
15
15
|
bExcludeWhenNotAdmin: false,
|
|
16
16
|
|
|
17
17
|
serverPort: 11005,
|
|
18
|
+
subfolder: '', //mpai
|
|
18
19
|
|
|
19
20
|
webName: {
|
|
20
21
|
'eng': 'API Service',
|
|
@@ -29,10 +30,11 @@ let opt = {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
//WWebApi
|
|
32
|
-
WWebApi(WOrm, url, db, opt)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let instWWebApi = WWebApi(WOrm, url, db, opt)
|
|
34
|
+
|
|
35
|
+
instWWebApi.on('error', (err) => {
|
|
36
|
+
console.log(err)
|
|
37
|
+
})
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
//node --experimental-modules --es-module-specifier-resolution=node srv.mjs
|
package/tableTags-web-api.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"apis":"
|
|
1
|
+
{"apis":"hWgeMc"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
// import _ from 'lodash'
|
|
4
|
+
import w from 'wsemi'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let fdTar = './dist'
|
|
8
|
+
let fnEntryIn = 'index.html'
|
|
9
|
+
let fnEntryOut = 'index.tmp'
|
|
10
|
+
let fpEntryIn = path.resolve(fdTar, fnEntryIn)
|
|
11
|
+
let fpEntryOut = path.resolve(fdTar, fnEntryOut)
|
|
12
|
+
|
|
13
|
+
//readFileSync
|
|
14
|
+
let c = fs.readFileSync(fpEntryIn, 'utf8')
|
|
15
|
+
|
|
16
|
+
//replace
|
|
17
|
+
c = w.replace(c, '/mapi/', '{sfd}/')
|
|
18
|
+
|
|
19
|
+
//writeFileSync
|
|
20
|
+
fs.writeFileSync(fpEntryOut, c, 'utf8')
|
|
21
|
+
|
|
22
|
+
//unlinkSync
|
|
23
|
+
fs.unlinkSync(fpEntryIn)
|
package/vue.config.js
CHANGED
package/dist/index.html
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title></title><link href="https://cdn.jsdelivr.net/npm/@mdi/font/css/materialdesignicons.min.css" rel="stylesheet"><link href="https://pro.fontawesome.com/releases/v5.15.4/css/all.css" rel="stylesheet"><link href="/css/app.5eff8f8a.css" rel="preload" as="style"><link href="/css/chunk-vendors.f0a39794.css" rel="preload" as="style"><link href="/js/app.3862cf85.js" rel="preload" as="script"><link href="/js/chunk-vendors.07b6a404.js" rel="preload" as="script"><link href="/css/chunk-vendors.f0a39794.css" rel="stylesheet"><link href="/css/app.5eff8f8a.css" rel="stylesheet"></head><body style="font-family:'Microsoft JhengHei','Avenir','Helvetica', 'Arial', 'sans-serif'; padding:0px; margin:0px;"><noscript><strong>We're sorry but w-component-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.07b6a404.js"></script><script src="/js/app.3862cf85.js"></script></body></html>
|