@rpcbase/server 0.129.0 → 0.131.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/express/index.js +9 -3
- package/package.json +1 -1
- package/queue/register_queue_listener.js +4 -11
package/express/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
+
const debug = require("debug")
|
|
2
3
|
const cors = require("cors")
|
|
3
4
|
const express = require("express")
|
|
4
5
|
const body_parser = require("body-parser")
|
|
@@ -12,9 +13,12 @@ const dev_stop_timeout = require("./dev_stop_timeout")
|
|
|
12
13
|
const session_middleware = require("./session_middleware")
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
const log = debug("rb:server")
|
|
17
|
+
|
|
15
18
|
const is_production = process.env.IS_PRODUCTION === "yes"
|
|
16
19
|
const {APP_DOMAIN, CLIENT_PORT} = process.env
|
|
17
20
|
|
|
21
|
+
log("server is production:", JSON.stringify(is_production))
|
|
18
22
|
|
|
19
23
|
module.exports = () => {
|
|
20
24
|
const app = express()
|
|
@@ -35,6 +39,7 @@ module.exports = () => {
|
|
|
35
39
|
next()
|
|
36
40
|
})
|
|
37
41
|
|
|
42
|
+
|
|
38
43
|
// CORS
|
|
39
44
|
const cors_origins = is_production ?
|
|
40
45
|
// https://stackoverflow.com/questions/14003332/access-control-allow-origin-wildcard-subdomains-ports-and-protocols
|
|
@@ -48,14 +53,15 @@ module.exports = () => {
|
|
|
48
53
|
// local dev origins
|
|
49
54
|
[
|
|
50
55
|
`http://localhost:${CLIENT_PORT}`,
|
|
51
|
-
`http://192.168.1.83:${CLIENT_PORT}`,
|
|
52
|
-
`http://192.168.1.140:${CLIENT_PORT}`,
|
|
56
|
+
// `http://192.168.1.83:${CLIENT_PORT}`,
|
|
57
|
+
// `http://192.168.1.140:${CLIENT_PORT}`,
|
|
53
58
|
`http://admin.localhost:${CLIENT_PORT}`,
|
|
54
|
-
// WARNING: hardcoded port
|
|
59
|
+
// TODO: WARNING: TMP hardcoded port
|
|
55
60
|
"http://localhost:8090", // TMP: used by inspected app from admin
|
|
56
61
|
"http://localhost:9292", // TMP
|
|
57
62
|
"localhost",
|
|
58
63
|
]
|
|
64
|
+
log("setting up cors with origins", JSON.stringify(cors_origins))
|
|
59
65
|
|
|
60
66
|
app.use(cors({
|
|
61
67
|
origin: cors_origins,
|
package/package.json
CHANGED
|
@@ -62,32 +62,25 @@ const register_model_emitter = (model_name) => {
|
|
|
62
62
|
// console.log("args", arg, arg2)
|
|
63
63
|
// const stack = new Error()
|
|
64
64
|
// console.log(stack.stack)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
register_model_emitter(model_name)
|
|
67
|
+
}, 500)
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
const register_queue_listener = async() => {
|
|
73
73
|
mongoose.connection.once("open", () => {
|
|
74
|
-
console.log("CONNEC OPEN")
|
|
75
|
-
// console.log("returning")
|
|
76
|
-
// return
|
|
74
|
+
console.log("CONNEC OPEN:register_queue_listener")
|
|
77
75
|
// register the mongoose delete plugin
|
|
78
76
|
mongoose.plugin(mongoose_delete_plugin)
|
|
79
77
|
|
|
80
78
|
const models = mongoose.modelNames()
|
|
81
79
|
|
|
82
|
-
console.log("GOT MODEL NAMES", models)
|
|
83
|
-
|
|
84
80
|
console.log("WILL register_model_emitter")
|
|
85
81
|
|
|
86
82
|
models.forEach(register_model_emitter)
|
|
87
|
-
|
|
88
83
|
})
|
|
89
|
-
|
|
90
|
-
console.log("ICICICICICIICICICICICI")
|
|
91
84
|
}
|
|
92
85
|
|
|
93
86
|
|