@live-change/server 0.7.12 → 0.7.15
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/lib/SsrServer.js +15 -3
- package/lib/setupApiServer.js +7 -1
- package/package.json +3 -3
package/lib/SsrServer.js
CHANGED
|
@@ -17,7 +17,9 @@ class SsrServer {
|
|
|
17
17
|
|
|
18
18
|
this.version = settings.version || 'unknown'
|
|
19
19
|
this.express = express
|
|
20
|
-
this.
|
|
20
|
+
if(!this.settings.spa || this.settings.dev) {
|
|
21
|
+
this.renderer = new Renderer(manifest, settings)
|
|
22
|
+
}
|
|
21
23
|
|
|
22
24
|
this.instanceId = encodeNumber(hashCode(
|
|
23
25
|
`ssr${process.pid}${require("os").hostname()} ${process.cwd()}/${process.argv.join(' ')}`))
|
|
@@ -27,12 +29,14 @@ class SsrServer {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
async start() {
|
|
30
|
-
|
|
32
|
+
if(this.renderer) {
|
|
33
|
+
await this.renderer.start()
|
|
34
|
+
}
|
|
31
35
|
|
|
32
36
|
if(this.settings.dev) {
|
|
33
37
|
this.express.use(this.renderer.vite.middlewares)
|
|
34
38
|
} else {
|
|
35
|
-
const staticPath = path.resolve(this.root, 'dist/client')
|
|
39
|
+
const staticPath = path.resolve(this.root, this.settings.spa ? 'dist/spa' : 'dist/client')
|
|
36
40
|
this.express.use('/', expressStaticGzip(staticPath, {
|
|
37
41
|
//enableBrotli: true,
|
|
38
42
|
index: false,
|
|
@@ -95,6 +99,14 @@ class SsrServer {
|
|
|
95
99
|
this.renderer.renderSitemap({ dao, clientIp }, res)
|
|
96
100
|
})
|
|
97
101
|
this.express.use('*', async (req, res) => {
|
|
102
|
+
if(this.settings.spa) {
|
|
103
|
+
if(this.settings.dev) {
|
|
104
|
+
res.sendFile(path.resolve(this.root, 'index.html'))
|
|
105
|
+
} else {
|
|
106
|
+
res.sendFile(path.resolve(this.root, 'dist/spa/index.html'))
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
98
110
|
const url = req.originalUrl
|
|
99
111
|
const clientIp = getIp(req)
|
|
100
112
|
|
package/lib/setupApiServer.js
CHANGED
|
@@ -46,7 +46,8 @@ async function setupApiServer(settings) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
})
|
|
49
|
+
}),
|
|
50
|
+
...(typeof services.config.local === 'function' ? services.config.local(credentials) : services.config.local)
|
|
50
51
|
}
|
|
51
52
|
if(settings.dbAccess) {
|
|
52
53
|
local.serverDatabase = {
|
|
@@ -63,6 +64,11 @@ async function setupApiServer(settings) {
|
|
|
63
64
|
}
|
|
64
65
|
return local
|
|
65
66
|
},
|
|
67
|
+
remote(credentials) {
|
|
68
|
+
return {
|
|
69
|
+
...(typeof services.config.remote === 'function' ? services.config.remote(credentials) : services.config.remote)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
66
72
|
shareDefinition: true,
|
|
67
73
|
logErrors: true,
|
|
68
74
|
createSessionOnUpdate: true, /// deprecated - moved to session-service settings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/server",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.15",
|
|
4
4
|
"description": "Live Change Framework - server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@live-change/dao": "0.5.9",
|
|
25
25
|
"@live-change/dao-sockjs": "0.5.9",
|
|
26
26
|
"@live-change/db-server": "0.5.23",
|
|
27
|
-
"@live-change/framework": "^0.7.
|
|
27
|
+
"@live-change/framework": "^0.7.15",
|
|
28
28
|
"@live-change/sockjs": "0.4.1",
|
|
29
29
|
"@live-change/uid": "0.7.11",
|
|
30
30
|
"dotenv": "^16.0.1",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"websocket": "^1.0.34",
|
|
40
40
|
"yargs": "^17.5.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "9e2d54359edb2619024512f95ba6900734e7b3a1"
|
|
43
43
|
}
|