forked from Systho/ipl-web3-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Laurent Leleux
committed
Oct 8, 2018
1 parent
d605b13
commit 0283053
Showing
8 changed files
with
11,206 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
node_modules | ||
dist | ||
*.log | ||
*.log | ||
.env |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Imports | ||
*/ | ||
const MongoClient = require('mongodb').MongoClient; | ||
const assert = require('assert'); | ||
|
||
|
||
|
||
/** | ||
* Variables | ||
*/ | ||
// Connection URL | ||
const url = process.env.DB_URL; | ||
// Database Name | ||
const dbName = process.env.DB_DB; | ||
|
||
|
||
|
||
/** | ||
* Connect to the database | ||
*/ | ||
let connect = () => { | ||
return new Promise((resolve, reject) => { | ||
const client = new MongoClient(url); | ||
client.connect(function(err) { | ||
if (err) { | ||
console.log("[DB] Unable to connect to server: " + err.message); | ||
reject(err); | ||
} else { | ||
console.log("[DB] Connected successfully to server"); | ||
exports.db = client.db(dbName); | ||
resolve(exports.db); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
|
||
|
||
/** | ||
* Exports | ||
*/ | ||
exports.connect = connect; | ||
exports.db = null; // db will be set after connected; |
This file contains 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
Oops, something went wrong.