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