@rpcbase/server 0.28.0 → 0.32.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/database.js +1 -0
- package/express/index.js +5 -4
- package/express/{session.js → session_middleware.js} +13 -15
- package/index.js +0 -2
- package/mongoose/index.js +0 -3
- package/package.json +1 -1
- package/rpc/rpc_router.js +3 -2
- package/mongoose/rts_delete_plugin.js +0 -12
package/database.js
CHANGED
|
@@ -15,6 +15,7 @@ if (typeof DATABASE_NAME !== "string") {
|
|
|
15
15
|
const mongo_url = `mongodb://database:${DATABASE_PORT}/${DATABASE_NAME}`
|
|
16
16
|
|
|
17
17
|
module.exports = async() => {
|
|
18
|
+
console.log("setup DB", mongo_url)
|
|
18
19
|
const ret = await mongoose.connect(mongo_url)
|
|
19
20
|
// TODO: handle connection ret
|
|
20
21
|
// console.log(ret)
|
package/express/index.js
CHANGED
|
@@ -3,7 +3,7 @@ const cors = require("cors")
|
|
|
3
3
|
const express = require("express")
|
|
4
4
|
const body_parser = require("body-parser")
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const session_middleware = require("./session_middleware")
|
|
7
7
|
|
|
8
8
|
const is_production = process.env.IS_PRODUCTION === "yes"
|
|
9
9
|
const {APP_DOMAIN, CLIENT_PORT} = process.env
|
|
@@ -17,7 +17,6 @@ module.exports = () => {
|
|
|
17
17
|
|
|
18
18
|
app.disable("x-powered-by")
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
// tmp disable aggressive caching
|
|
22
21
|
app.set("etag", false)
|
|
23
22
|
|
|
@@ -42,14 +41,16 @@ module.exports = () => {
|
|
|
42
41
|
"http://localhost:8090",
|
|
43
42
|
"localhost",
|
|
44
43
|
]
|
|
45
|
-
console.log("SETUP CORS", cors_origins)
|
|
44
|
+
// console.log("SETUP CORS", cors_origins)
|
|
45
|
+
|
|
46
46
|
app.use(cors({
|
|
47
47
|
origin: cors_origins,
|
|
48
48
|
methods: ["GET", "POST"],
|
|
49
49
|
credentials: true // enable set-cookie
|
|
50
50
|
}))
|
|
51
51
|
|
|
52
|
-
session
|
|
52
|
+
console.log("use session middleware")
|
|
53
|
+
app.use(session_middleware)
|
|
53
54
|
|
|
54
55
|
app.get("/api/ping", (req, res) => res.json({status: "ok"}))
|
|
55
56
|
|
|
@@ -4,6 +4,7 @@ const redis = require("redis")
|
|
|
4
4
|
const validator = require("validator")
|
|
5
5
|
const redis_store = require("connect-redis")(session)
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
const {SESSION_STORE_PORT} = process.env
|
|
8
9
|
|
|
9
10
|
if (typeof SESSION_STORE_PORT === "string" && !validator.isPort(SESSION_STORE_PORT)) {
|
|
@@ -12,20 +13,17 @@ if (typeof SESSION_STORE_PORT === "string" && !validator.isPort(SESSION_STORE_PO
|
|
|
12
13
|
|
|
13
14
|
const session_store_url = `redis://session-store:${SESSION_STORE_PORT}`
|
|
14
15
|
|
|
16
|
+
const redis_client = redis.createClient({
|
|
17
|
+
url: session_store_url
|
|
18
|
+
})
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const session_middleware = session({
|
|
21
|
+
store: new redis_store({client: redis_client}),
|
|
22
|
+
proxy: true,
|
|
23
|
+
saveUninitialized: false,
|
|
24
|
+
// TODO: fix session secret
|
|
25
|
+
secret: "session secret wowow",
|
|
26
|
+
resave: false,
|
|
27
|
+
})
|
|
20
28
|
|
|
21
|
-
|
|
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
|
-
}
|
|
29
|
+
module.exports = session_middleware
|
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const client_router = require("./client/client_router")
|
|
3
3
|
const database = require("./database")
|
|
4
4
|
const express = require("./express")
|
|
5
|
-
const mongoose = require("./mongoose")
|
|
6
5
|
const rpc_router = require("./rpc/rpc_router")
|
|
7
6
|
|
|
8
7
|
|
|
@@ -10,6 +9,5 @@ module.exports = {
|
|
|
10
9
|
client_router,
|
|
11
10
|
database,
|
|
12
11
|
express,
|
|
13
|
-
mongoose,
|
|
14
12
|
rpc_router,
|
|
15
13
|
}
|
package/mongoose/index.js
CHANGED
package/package.json
CHANGED
package/rpc/rpc_router.js
CHANGED
|
@@ -30,8 +30,9 @@ const rpc_router = (app) => {
|
|
|
30
30
|
const rpc_fn = require(module_path)
|
|
31
31
|
app.post(`/rpc/${route_path}`, async_wrapper(async(req, res) => {
|
|
32
32
|
// console.log("GOT REQ", req.body)
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// TODO: add jaegerclient / opentelemetry
|
|
34
|
+
const result = await rpc_fn(req.body, {req})
|
|
35
|
+
|
|
35
36
|
res.json(result)
|
|
36
37
|
}))
|
|
37
38
|
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
// fixes the mongodb issue with missing fullDocument in change streams
|
|
4
|
-
// that is required for dispatching to proper sockets in real time state
|
|
5
|
-
|
|
6
|
-
module.exports = (schema, options) => {
|
|
7
|
-
console.log("MONGOOSE DELETE PLUGIN")
|
|
8
|
-
|
|
9
|
-
schema.post("remove", (arg, arg2) => {
|
|
10
|
-
console.log("DELETE WOWO", arg, arg2)
|
|
11
|
-
})
|
|
12
|
-
}
|