Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Server.js
- const express = require('express');
- const app = express();
- const BP = require('body-parser');
- const mongoose = require('mongoose');
- const todos = require('./Router/index');
- const url = 'pake mongodb atlas';
- mongoose.connect(url, {useNewUrlParser: true});
- mongoose.Promise = global.Promise;
- const db = mongoose.connection;
- db.on('error', console.error.bind(console, 'connection error:'));
- db.once('open', function() {
- // we're connected!
- console.log('we\'re connected to mongodb atlas');
- });
- app.use(BP.json());
- app.use(BP.urlencoded({extended : false}));
- app.use('/api', todos);
- app.listen(3000, () => console.log('running on port 3000..'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement