Fix database connection.
This commit is contained in:
@@ -6,7 +6,7 @@ services:
|
||||
ports:
|
||||
- "27017:27017"
|
||||
environment:
|
||||
- "MONGO_INITDB_DATABASE=express-test"
|
||||
- "MONGO_INITDB_DATABASE=db_application"
|
||||
- "MONGO_INITDB_ROOT_USERNAME=god"
|
||||
- "MONGO_INITDB_ROOT_PASSWORD=P@ssword"
|
||||
volumes:
|
||||
|
||||
@@ -3,7 +3,7 @@ db.test.insert({id: 'test'});
|
||||
db.createUser(
|
||||
{
|
||||
user: "application_user",
|
||||
pwd: "Password1",
|
||||
pwd: "P@ssword1",
|
||||
roles:
|
||||
[
|
||||
{ role: "readWrite", db: "db_application" }
|
||||
|
||||
@@ -3,10 +3,12 @@ const configuration = require('../configuration');
|
||||
const mongoConfig = configuration.mongodb;
|
||||
|
||||
function buildDatabaseUrl() {
|
||||
const username = mongoConfig.username;
|
||||
const username = encodeURIComponent(mongoConfig.username);
|
||||
const password = encodeURIComponent(mongoConfig.password);
|
||||
const url = `${mongoConfig.url}:${mongoConfig.port}`;
|
||||
const test = `mongodb://${username}:${password}@${url}`;
|
||||
const url = mongoConfig.url;
|
||||
const port = mongoConfig.port;
|
||||
const database = mongoConfig.database;
|
||||
const test = `mongodb://${username}:${password}@${url}:${port}/${database}`;
|
||||
console.log(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ mongodb:
|
||||
url: 'localhost'
|
||||
port: 27017
|
||||
username: 'application_user'
|
||||
password: 'Password1'
|
||||
password: 'P@ssword1'
|
||||
database: 'db_application'
|
||||
security:
|
||||
jwt:
|
||||
|
||||
Reference in New Issue
Block a user