@rpcbase/server 0.6.0 → 0.10.0
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/cli/start_server.js +3 -0
- package/client/client_router.js +8 -2
- package/index.js +2 -0
- package/package.json +4 -3
- package/realtime-state/sockets.js +8 -0
package/cli/start_server.js
CHANGED
|
@@ -5,6 +5,9 @@ const fs = require("fs")
|
|
|
5
5
|
|
|
6
6
|
const is_production = "yes" === process.env.INFRASTRUCTURE_IS_PRODUCTION
|
|
7
7
|
|
|
8
|
+
// TODO: auto create network if necessary
|
|
9
|
+
// docker network create local-network
|
|
10
|
+
|
|
8
11
|
const start_server = async() => {
|
|
9
12
|
if (is_production) {
|
|
10
13
|
console.log("server will run in production")
|
package/client/client_router.js
CHANGED
|
@@ -6,12 +6,10 @@ const glob = require("glob")
|
|
|
6
6
|
const src_path = path.join(process.cwd(), "./src/")
|
|
7
7
|
const build_dir = path.join(process.cwd(), "build/")
|
|
8
8
|
const client_build_dir = path.join(build_dir, "./client")
|
|
9
|
-
const index_file_buffer = fs.readFileSync(path.join(client_build_dir, "./index.html"))
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
// TODO: add build time static assets compression
|
|
13
12
|
|
|
14
|
-
|
|
15
13
|
const async_wrapper = fn => (req, res, next) => {
|
|
16
14
|
Promise.resolve(fn(req, res, next))
|
|
17
15
|
.catch(next)
|
|
@@ -32,6 +30,14 @@ const get_client_routes = () => {
|
|
|
32
30
|
const client_router = (app) => {
|
|
33
31
|
const client_routes = get_client_routes()
|
|
34
32
|
|
|
33
|
+
const index_file_path = path.join(client_build_dir, "./index.html")
|
|
34
|
+
if (!fs.existsSync(index_file_path)) {
|
|
35
|
+
console.log("index file not found, skipping server:client_router")
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const index_file_buffer = fs.readFileSync(index_file_path)
|
|
40
|
+
|
|
35
41
|
app.get("*", async_wrapper(async(req, res, next) => {
|
|
36
42
|
const full_path = req.baseUrl + req.path
|
|
37
43
|
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"connect-redis": "6.0.0",
|
|
14
14
|
"dotenv": "10.0.0",
|
|
15
15
|
"glob": "7.2.0",
|
|
16
|
-
"redis": "
|
|
17
|
-
"
|
|
16
|
+
"redis": "4.0.1",
|
|
17
|
+
"socket.io": "4.4.0",
|
|
18
|
+
"yargs": "17.3.1"
|
|
18
19
|
}
|
|
19
20
|
}
|