@rpcbase/server 0.10.0 → 0.14.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.
@@ -0,0 +1,24 @@
1
+ /* @flow */
2
+ const express = require("express")
3
+
4
+ const session = require("./session")
5
+
6
+
7
+ module.exports = () => {
8
+ const app = express()
9
+ app.use(body_parser.json())
10
+
11
+ app.set("trust proxy", 1)
12
+
13
+ app.disable("x-powered-by")
14
+ app.set("etag", false)
15
+
16
+ app.use((req, res, next) => {
17
+ res.set("Cache-Control", "no-store")
18
+ next()
19
+ })
20
+
21
+ session(app)
22
+
23
+ return app
24
+ }
@@ -0,0 +1,31 @@
1
+ /* @flow */
2
+ const session = require("express-session")
3
+ const redis = require("redis")
4
+ const validator = require("validator")
5
+ const redis_store = require("connect-redis")(session)
6
+
7
+ const {SESSION_STORE_PORT} = process.env
8
+
9
+ if (!validator.isPort(SESSION_STORE_PORT)) {
10
+ throw new Error("expected SESSION_STORE_PORT to be a valid port number")
11
+ }
12
+
13
+ const session_store_url = `redis://session-store:${SESSION_STORE_PORT}`
14
+
15
+
16
+ module.exports = (app) => {
17
+ const redis_client = redis.createClient({
18
+ url: session_store_url
19
+ })
20
+
21
+ app.use(
22
+ session({
23
+ store: new redis_store({client: redis_client}),
24
+ proxy: true,
25
+ saveUninitialized: false,
26
+ // TODO: fix session secret
27
+ secret: "session secret wowow",
28
+ resave: false,
29
+ })
30
+ )
31
+ }
package/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  /* @flow */
2
2
  const rpc_router = require("./rpc/rpc_router")
3
3
  const client_router = require("./client/client_router")
4
- const sockets = require("./realtime-state/sockets")
5
4
 
6
5
  module.exports = {
6
+ express,
7
7
  rpc_router,
8
8
  client_router,
9
- sockets,
10
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.10.0",
3
+ "version": "0.14.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,11 +10,14 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 0"
11
11
  },
12
12
  "dependencies": {
13
+ "body-parser": "1.19.1",
13
14
  "connect-redis": "6.0.0",
14
15
  "dotenv": "10.0.0",
16
+ "express": "4.17.2",
17
+ "express-session": "1.17.2",
15
18
  "glob": "7.2.0",
16
- "redis": "4.0.1",
17
- "socket.io": "4.4.0",
19
+ "redis": "3.1.2",
20
+ "validator": "13.7.0",
18
21
  "yargs": "17.3.1"
19
22
  }
20
23
  }
@@ -1,8 +0,0 @@
1
- /* @flow */
2
-
3
- const init_sockets = async(app) => {
4
- console.log("ici init sockets")
5
- }
6
-
7
-
8
- module.exports = init_sockets