Last active
January 4, 2019 20:09
-
-
Save nomoney4me/a0edbd41b7b5a51599ac7ff775296476 to your computer and use it in GitHub Desktop.
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
// Set up default mongoose connection | |
const mongoDB = 'mongodb://127.0.0.1/chatpoint'; | |
mongoose.connect(mongoDB); | |
// Get Mongoose to use the global promise library | |
mongoose.Promise = global.Promise; | |
// Get the default connection | |
const db = mongoose.connection; | |
// Bind connection to error event (to get notification of connection errors) | |
db.on('error', console.error.bind(console, 'MongoDB connection error:')); | |
module.exports = db |
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
var express = require('express'); | |
var router = express.Router(); | |
const db = require('./db.js'); | |
/* GET users listing. */ | |
router.get('/', (req, res, next) => { | |
res.send('respond with a resource'); | |
}); | |
/* POST new user. */ | |
router.post('/', (req, res, next) => { | |
// db.collection() ??? untested... | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment