w-web-api 1.0.19 → 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/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#line69">line 69</a>
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
  console.log(err)
136
+ <pre class="prettyprint"><code>import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
137
137
  getUserById: null,
138
138
  bCheckUser: false,
139
139
  bExcludeWhenNotAdmin: false,
140
140
  serverPort: 11005,
141
141
  subfolder: '', //mpai
142
142
  webName: {
143
143
  'eng': 'API Service',
144
144
  'cht': 'API管理系統'
145
145
  },
146
146
  console.log(err)
147
147
 
148
148
 
149
149
 
@@ -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
+ &lt;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
+ &lt;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
+ &lt;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 Wed May 11 2022 17:06:59 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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>
@@ -42,21 +42,26 @@
42
42
 
43
43
  <section>
44
44
  <article>
45
- <pre class="prettyprint source linenums"><code>import get from 'lodash/get'
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 b642str from 'wsemi/src/b642str'
59
- import fsIsFolder from 'wsemi/src/fsIsFolder'
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',
@@ -164,7 +173,19 @@ function WWebApi(WOrm, url, db, opt = {}) {
164
173
 
165
174
 
166
175
  //webLogo
167
- 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
+ }
168
189
 
169
190
 
170
191
  //WServOrm
@@ -286,6 +307,16 @@ function WWebApi(WOrm, url, db, opt = {}) {
286
307
  // console.log('pathStaticFiles', pathStaticFiles)
287
308
 
288
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
+
289
320
  //apis
290
321
  let apis = [
291
322
  // {
@@ -407,7 +438,7 @@ export default WWebApi
407
438
  <br class="clear">
408
439
 
409
440
  <footer>
410
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed May 11 2022 17:06:59 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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.
411
442
  </footer>
412
443
 
413
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 Wed May 11 2022 17:06:59 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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.19",
3
+ "version": "1.0.20",
4
4
  "main": "dist/w-web-api.umd.js",
5
5
  "dependencies": {
6
6
  "@mdi/js": "^6.6.96",
@@ -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 b642str from 'wsemi/src/b642str'
15
- import fsIsFolder from 'wsemi/src/fsIsFolder'
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',
@@ -120,7 +129,19 @@ function WWebApi(WOrm, url, db, opt = {}) {
120
129
 
121
130
 
122
131
  //webLogo
123
- 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
+ }
124
145
 
125
146
 
126
147
  //WServOrm
@@ -242,6 +263,16 @@ function WWebApi(WOrm, url, db, opt = {}) {
242
263
  // console.log('pathStaticFiles', pathStaticFiles)
243
264
 
244
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
+
245
276
  //apis
246
277
  let apis = [
247
278
  // {
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',
@@ -1 +1 @@
1
- {"apis":"Au5CHL"}
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
@@ -11,5 +11,5 @@ module.exports = {
11
11
  }
12
12
  },
13
13
  // transpileDependencies: ['vuetify'],
14
- publicPath: process.env.NODE_ENV === 'production' ? '/mapi/' : '/',
14
+ publicPath: process.env.NODE_ENV === 'production' ? '/mapi/' : '/', //預先編譯至mapi子目錄下, 待啟動後取代
15
15
  }