@live-change/vue3-ssr 0.1.7 → 0.1.8
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/clientApi.js +2 -2
- package/package.json +1 -1
- package/getIp.js +0 -12
- package/serverDao.js +0 -56
package/clientApi.js
CHANGED
|
@@ -13,9 +13,9 @@ function clientApi(settings = {}) {
|
|
|
13
13
|
|
|
14
14
|
...settings,
|
|
15
15
|
|
|
16
|
-
fastAuth: !window.hasOwnProperty('__CREDENTIALS__'),
|
|
17
|
-
|
|
18
16
|
connectionSettings: {
|
|
17
|
+
fastAuth: !window.hasOwnProperty('__CREDENTIALS__'),
|
|
18
|
+
|
|
19
19
|
queueRequestsWhenDisconnected: true,
|
|
20
20
|
requestSendTimeout: Infinity,
|
|
21
21
|
requestTimeout: Infinity,
|
package/package.json
CHANGED
package/getIp.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function getIp(connection) {
|
|
2
|
-
let ip =
|
|
3
|
-
connection.headers['x-real-ip'] ||
|
|
4
|
-
connection.headers['x-forwarded-for'] ||
|
|
5
|
-
connection.remoteAddress ||
|
|
6
|
-
(connection.connection && connection.connection.remoteAddress)
|
|
7
|
-
ip = ip.split(',')[0]
|
|
8
|
-
ip = ip.split(':').slice(-1)[0] //in case the ip returned in a format: "::ffff:146.xxx.xxx.xxx"
|
|
9
|
-
return ip
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = getIp
|
package/serverDao.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const { Dao } = require("@live-change/dao")
|
|
2
|
-
const DaoWebsocket = require("@live-change/dao-websocket")
|
|
3
|
-
|
|
4
|
-
function reactiveObservableListConstructor(reactive) {
|
|
5
|
-
class ReactiveObservableList extends Dao.ObservableList {
|
|
6
|
-
constructor(value, what, dispose) {
|
|
7
|
-
super(value, what, dispose, (data) => {
|
|
8
|
-
if(data && typeof data == 'object') {
|
|
9
|
-
const activated = reactive(data)
|
|
10
|
-
return activated
|
|
11
|
-
}
|
|
12
|
-
return data
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return ReactiveObservableList
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function serverDao(credentials, ip, settings) {
|
|
20
|
-
const serverHost = settings.remoteUrl || process.env.API_SERVER || "localhost:" + (process.env.API_PORT || 8002)
|
|
21
|
-
const wsServer = `ws://${serverHost}/api/ws`
|
|
22
|
-
|
|
23
|
-
return new Dao(credentials, {
|
|
24
|
-
remoteUrl: wsServer,
|
|
25
|
-
protocols: {
|
|
26
|
-
'ws': DaoWebsocket.client
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
...settings,
|
|
30
|
-
|
|
31
|
-
connectionSettings: {
|
|
32
|
-
headers: {
|
|
33
|
-
'X-real-ip': ip,
|
|
34
|
-
'X-forwarded-for': ip
|
|
35
|
-
},
|
|
36
|
-
queueRequestsWhenDisconnected: true,
|
|
37
|
-
requestSendTimeout: 2300,
|
|
38
|
-
requestTimeout: 10000,
|
|
39
|
-
queueActiveRequestsOnDisconnect: false,
|
|
40
|
-
autoReconnectDelay: 200,
|
|
41
|
-
logLevel: 1,
|
|
42
|
-
/*connectionMonitorFactory: (connection) =>
|
|
43
|
-
new ReactiveDao.ConnectionMonitorPinger(connection, {
|
|
44
|
-
pingInterval: 50,
|
|
45
|
-
pongInterval: 200
|
|
46
|
-
})*/
|
|
47
|
-
...(settings && settings.connectionSettings)
|
|
48
|
-
},
|
|
49
|
-
defaultRoute: {
|
|
50
|
-
type: "remote",
|
|
51
|
-
generator: settings.reactive ? reactiveObservableListConstructor(settings.reactive) : Dao.ObservableList
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = serverDao
|