Created
July 30, 2017 10:01
-
-
Save gaboelnuevo/87586be144721f3b8d561410690915a0 to your computer and use it in GitHub Desktop.
loopback mongo uri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// serve/datasources.local.js | |
var mongodbUri = require('mongodb-uri'); | |
var URI = process.env.MONGODB_URI; | |
var uriObject = URI ? mongodbUri.parse(URI) : null; | |
var config = {}; | |
if (uriObject && uriObject.hosts.length >= 1) { | |
config.db = { | |
name: 'db', | |
connector: 'mongodb', | |
host: uriObject.hosts[0].host, | |
port: uriObject.hosts[0].port, | |
database: uriObject.database, | |
username: uriObject.username, | |
password: uriObject.password, | |
}; | |
} | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment