Skip to content
Commits on Source (6)
# Changelog
## [1.1.3](https://gitlab.mim-libre.fr/alphabet/laboite-blog-api/compare/release/1.1.2...release/1.1.3) (2022-01-18)
### Bug Fixes
* **auth:** change authentication method for mongodb ([2e3a71e](https://gitlab.mim-libre.fr/alphabet/laboite-blog-api/commit/2e3a71ef5012ed49a347dc9b7e63e4e91d80f3cd))
* **config:** add checks and logs for mongo configuration ([e4d6757](https://gitlab.mim-libre.fr/alphabet/laboite-blog-api/commit/e4d6757db32977c5abe48aa30a6e648cb5e92d24))
## [1.1.2](https://gitlab.mim-libre.fr/alphabet/laboite-blog-api/compare/release/1.1.1...release/1.1.2) (2022-01-13)
......
{
"name": "laboite-blog-backend",
"version": "1.1.2",
"version": "1.1.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "laboite-blog-backend",
"version": "1.1.2",
"version": "1.1.3",
"description": " API backend for laboite blog service",
"keywords": [
"loopback-application",
......
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
const config = {
name: 'db',
connector: 'mongodb',
host: process.env.MONGO_HOST,
port: process.env.MONGO_PORT,
user: encodeURIComponent(process.env.MONGO_USER || ''),
password: encodeURIComponent(process.env.MONGO_PASSWORD || ''),
database: process.env.MONGO_DATABASE,
useNewUrlParser: true
};
let config = {}
try {
config = {
url: process.env.MONGO_USER ?
`mongodb://${encodeURIComponent(process.env.MONGO_USER || "")}:${encodeURIComponent(process.env.MONGO_PASSWORD || "")}@${process.env.MONGO_HOST}:${process.env.MONGO_PORT || 27017}/${process.env.MONGO_DATABASE}` :
`mongodb://${process.env.MONGO_HOST}:${process.env.MONGO_PORT || 27017}/${process.env.MONGO_DATABASE}`,
name: 'db',
connector: 'mongodb',
host: '',
port: 0,
user: '',
password: '',
database: '',
useNewUrlParser: true
};
} catch (err) {
console.log('! Error while parsing MongoDB configuration !')
console.log(err);
process.exit(1);
}
console.log(` - Connecting to MongoDB at ${process.env.MONGO_HOST}:${process.env.MONGO_PORT || 27017}, database: ${process.env.MONGO_DATABASE}`)
if (process.env.MONGO_USER) console.log(` Database user is ${process.env.MONGO_USER}`)
// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
......
......@@ -36,4 +36,5 @@ if (require.main === module) {
console.error('Cannot start the application.', err);
process.exit(1);
});
console.log(` - Started API server on port ${config.rest.port}`)
}