Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. // Server.js
  2. const express = require('express');
  3. const app = express();
  4. const BP = require('body-parser');
  5. const mongoose = require('mongoose');
  6. const todos = require('./Router/index');
  7.  
  8. const url = 'pake mongodb atlas';
  9. mongoose.connect(url, {useNewUrlParser: true});
  10. mongoose.Promise = global.Promise;
  11. const db = mongoose.connection;
  12. db.on('error', console.error.bind(console, 'connection error:'));
  13. db.once('open', function() {
  14. // we're connected!
  15. console.log('we\'re connected to mongodb atlas');
  16. });
  17.  
  18. app.use(BP.json());
  19. app.use(BP.urlencoded({extended : false}));
  20. app.use('/api', todos);
  21.  
  22. app.listen(3000, () => console.log('running on port 3000..'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement