Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Last active January 4, 2019 20:09
Show Gist options
  • Save nomoney4me/a0edbd41b7b5a51599ac7ff775296476 to your computer and use it in GitHub Desktop.
Save nomoney4me/a0edbd41b7b5a51599ac7ff775296476 to your computer and use it in GitHub Desktop.
// 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
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