@rpcbase/server 0.82.0 → 0.83.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 +5 -3
- package/package.json +1 -1
package/database.js
CHANGED
|
@@ -4,6 +4,9 @@ const isPort = require("validator/lib/isPort")
|
|
|
4
4
|
|
|
5
5
|
const {DATABASE_NAME, DATABASE_PORT, CONTAINER_MODE} = process.env
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
// database can be set by env variable or passed as paramaters to
|
|
9
|
+
|
|
7
10
|
if (typeof DATABASE_PORT !== "string" || !isPort(DATABASE_PORT)) {
|
|
8
11
|
throw new Error("expected DATABASE_PORT to be a valid port number")
|
|
9
12
|
}
|
|
@@ -17,9 +20,8 @@ const hostname = CONTAINER_MODE === "native" ? "localhost" : "database"
|
|
|
17
20
|
const mongo_url = `mongodb://${hostname}:${DATABASE_PORT}/${DATABASE_NAME}?directConnection=true&replicaSet=rs0`
|
|
18
21
|
|
|
19
22
|
|
|
20
|
-
// TODO: handle multiple databases, remove DATABASE_NAME env
|
|
21
|
-
|
|
22
|
-
module.exports = async() => {
|
|
23
|
+
// TODO: handle multiple databases, remove DATABASE_NAME env ??
|
|
24
|
+
module.exports = async(...database_names) => {
|
|
23
25
|
// set listeners before attempting to connect
|
|
24
26
|
mongoose.connection.on("connected", () => {
|
|
25
27
|
console.log("mongoose connected")
|