@rpcbase/server 0.31.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
CHANGED
|
@@ -15,7 +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("
|
|
18
|
+
console.log("setup DB", mongo_url)
|
|
19
19
|
const ret = await mongoose.connect(mongo_url)
|
|
20
20
|
// TODO: handle connection ret
|
|
21
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/mongoose/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
const mongoose = require("mongoose")
|
|
3
3
|
|
|
4
|
-
// browsers do not have mongoose plugins
|
|
5
|
-
if (typeof mongoose.plugin === "function") {
|
|
6
|
-
const rts_delete_plugin = require("./rts_delete_plugin")
|
|
7
|
-
mongoose.plugin(rts_delete_plugin)
|
|
8
|
-
}
|
|
9
4
|
|
|
10
5
|
module.exports = mongoose
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|