w-web-api 1.0.30 → 1.0.31
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 +16 -5
- package/dist/index.tmp +1 -1
- package/dist/js/{chunk-vendors.2a4fa50d.js → chunk-vendors-legacy.7033510d.js} +2 -2
- package/dist/js/chunk-vendors-legacy.7033510d.js.map +1 -0
- package/dist/js/{chunk-vendors-legacy.2a4fa50d.js → chunk-vendors.7033510d.js} +2 -2
- package/dist/js/chunk-vendors.7033510d.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 +42 -6
- package/docs/WWebApi.mjs.html +77 -24
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/server/WWebApi.mjs +76 -23
- package/srv.mjs +12 -4
- package/tableTags-web-api.json +1 -1
- package/dist/js/chunk-vendors-legacy.2a4fa50d.js.map +0 -1
- package/dist/js/chunk-vendors.2a4fa50d.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM,
|
|
|
24
24
|
import WWebApi from './server/WWebApi.mjs'
|
|
25
25
|
import getSettings from './g.getSettings.mjs'
|
|
26
26
|
|
|
27
|
+
|
|
27
28
|
//st
|
|
28
29
|
let st = getSettings()
|
|
29
30
|
|
|
@@ -37,6 +38,7 @@ let opt = {
|
|
|
37
38
|
|
|
38
39
|
serverPort: 11005,
|
|
39
40
|
subfolder: '', //mapi
|
|
41
|
+
urlRedirect: 'https://www.google.com/', //本機測試時得先編譯, 再瀏覽: http://localhost:11005/
|
|
40
42
|
|
|
41
43
|
webName: {
|
|
42
44
|
'eng': 'API Service',
|
|
@@ -50,13 +52,13 @@ let opt = {
|
|
|
50
52
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
let getUserByToken = (token) => {
|
|
55
|
+
let getUserByToken = async (token) => {
|
|
54
56
|
// return {} //測試無法登入
|
|
55
57
|
if (token === '{token-for-application}') { //提供外部應用系統作為存取使用者
|
|
56
58
|
return {
|
|
57
59
|
id: 'id-for-application',
|
|
58
60
|
name: 'application',
|
|
59
|
-
email: '
|
|
61
|
+
email: 'application@example.com',
|
|
60
62
|
isAdmin: 'y',
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -73,13 +75,22 @@ let getUserByToken = (token) => {
|
|
|
73
75
|
return {}
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
let
|
|
77
|
-
console.log('
|
|
78
|
+
let verifyBrowserUser = (user, caller) => {
|
|
79
|
+
console.log('verifyBrowserUser/user', user)
|
|
80
|
+
// return false //測試無法登入
|
|
81
|
+
console.log('於生產環境時得加入限制瀏覽器使用者身份機制')
|
|
82
|
+
return user.isAdmin === 'y' //測試僅系統管理者使用
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let verifyAppUser = (user, caller) => {
|
|
86
|
+
console.log('verifyAppUser/user', user)
|
|
87
|
+
// return false //測試無法登入
|
|
88
|
+
console.log('於生產環境時得加入限制應用程式使用者身份機制')
|
|
78
89
|
return user.isAdmin === 'y' //測試僅系統管理者使用
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
//WWebApi
|
|
82
|
-
let instWWebApi = WWebApi(WOrm, url, db, getUserByToken,
|
|
93
|
+
let instWWebApi = WWebApi(WOrm, url, db, getUserByToken, verifyBrowserUser, verifyAppUser, opt)
|
|
83
94
|
|
|
84
95
|
instWWebApi.on('error', (err) => {
|
|
85
96
|
console.log(err)
|
package/dist/index.tmp
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet"><script>window.___pmwapi___={
|
|
2
2
|
urlRedirect: '{urlRedirect}',
|
|
3
|
-
}</script><script defer="defer" type="module" src="{sfd}/js/chunk-vendors.
|
|
3
|
+
}</script><script defer="defer" type="module" src="{sfd}/js/chunk-vendors.7033510d.js"></script><script defer="defer" type="module" src="{sfd}/js/app.9b4e9f9b.js"></script><link href="{sfd}/css/app.d38a4241.css" rel="stylesheet"><script defer="defer" src="{sfd}/js/chunk-vendors-legacy.7033510d.js" nomodule></script><script defer="defer" src="{sfd}/js/app-legacy.9b4e9f9b.js" nomodule></script></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></body></html>
|