@live-change/server 0.1.18 → 0.1.19
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/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/lib/SsrServer.js +25 -11
- package/lib/TestServer.js +3 -2
- package/lib/setupApp.js +1 -1
- package/package.json +2 -2
- package/server.iml +9 -0
package/.idea/misc.xml
ADDED
package/.idea/vcs.xml
ADDED
package/lib/SsrServer.js
CHANGED
|
@@ -21,7 +21,7 @@ class SsrServer {
|
|
|
21
21
|
|
|
22
22
|
this.instanceId = encodeNumber(hashCode(
|
|
23
23
|
`ssr${process.pid}${require("os").hostname()} ${process.cwd()}/${process.argv.join(' ')}`))
|
|
24
|
-
this.uidGenerator = uidGenerator(this.instanceId, 1)
|
|
24
|
+
this.uidGenerator = uidGenerator(this.instanceId, 1, this.settings.uidBorders)
|
|
25
25
|
|
|
26
26
|
this.root = this.settings.root || process.cwd()
|
|
27
27
|
}
|
|
@@ -92,18 +92,32 @@ class SsrServer {
|
|
|
92
92
|
|
|
93
93
|
const version = this.version
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
let html
|
|
96
|
+
let error
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
for(let retry = 0; retry < 3; retry ++) {
|
|
99
|
+
try {
|
|
100
|
+
html = await this.renderer.renderPage({ url, dao, clientIp, credentials, windowId, version })
|
|
101
|
+
break
|
|
102
|
+
} catch(e) {
|
|
103
|
+
error = e
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if(html) {
|
|
107
|
+
res.status(200)
|
|
108
|
+
writeCredentials(res, credentials)
|
|
109
|
+
res.set({
|
|
110
|
+
'Content-Type': 'text/html'
|
|
111
|
+
})
|
|
112
|
+
res.end(html)
|
|
113
|
+
} else {
|
|
114
|
+
if(error.stack) this.renderer.fixStackTrace(error)
|
|
115
|
+
console.error("RENDERING ERROR", error.stack || error)
|
|
116
|
+
res.status(500).end(error.stack || error)
|
|
117
|
+
}
|
|
103
118
|
} catch (e) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
res.status(500).end(e.stack)
|
|
119
|
+
console.error("ERROR", e.stack || e)
|
|
120
|
+
res.status(500).end(e.stack || e)
|
|
107
121
|
}
|
|
108
122
|
})
|
|
109
123
|
}
|
package/lib/TestServer.js
CHANGED
|
@@ -27,7 +27,7 @@ class TestServer {
|
|
|
27
27
|
|
|
28
28
|
app.instanceId = encodeNumber(hashCode(
|
|
29
29
|
`app${process.pid}${require("os").hostname()} ${process.cwd()}/${process.argv.join(' ')}`))
|
|
30
|
-
app.uidGenerator = uidGenerator(app.instanceId, 1)
|
|
30
|
+
app.uidGenerator = uidGenerator(app.instanceId, 1, '[]')
|
|
31
31
|
this.dbServer = await setupDbServer({ dbBackend: 'mem' })
|
|
32
32
|
const loopbackDao = await createLoopbackDao('local', () => this.dbServer.createDao('local'))
|
|
33
33
|
app.dao = loopbackDao
|
|
@@ -60,8 +60,9 @@ class TestServer {
|
|
|
60
60
|
|
|
61
61
|
await new Promise((resolve, reject) => {
|
|
62
62
|
this.httpServer = this.expressServer.listen(this.config.port || 0, () => {
|
|
63
|
-
this.port = this.expressServer.address().port
|
|
63
|
+
this.port = this.expressServer.address().port
|
|
64
64
|
this.url = `http://localhost:${this.expressServer.address().port}`
|
|
65
|
+
process.env.SSR_PORT = this.port
|
|
65
66
|
resolve()
|
|
66
67
|
})
|
|
67
68
|
})
|
package/lib/setupApp.js
CHANGED
|
@@ -8,7 +8,7 @@ async function setupApp(settings, env = process.env) {
|
|
|
8
8
|
const app = require("@live-change/framework").app()
|
|
9
9
|
app.instanceId = encodeNumber(hashCode(
|
|
10
10
|
`app${process.pid}${require("os").hostname()} ${process.cwd()}/${process.argv.join(' ')}`))
|
|
11
|
-
app.uidGenerator = uidGenerator(app.instanceId, 1)
|
|
11
|
+
app.uidGenerator = uidGenerator(app.instanceId, 1, settings.uidBorders)
|
|
12
12
|
console.log("SETUP APP", settings)
|
|
13
13
|
let dbServer
|
|
14
14
|
if(settings.withDb) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Live Change Framework - server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@live-change/db-server": "^0.4.82",
|
|
27
27
|
"@live-change/framework": "^0.5.10",
|
|
28
28
|
"@live-change/vue3-ssr": "^0.1.7",
|
|
29
|
-
"@live-change/uid": "^0.1.
|
|
29
|
+
"@live-change/uid": "^0.1.4",
|
|
30
30
|
"http-proxy-middleware": "2.0.1",
|
|
31
31
|
"dotenv": "^10.0.0",
|
|
32
32
|
"express": "^4.17.1",
|
package/server.iml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|