// Setup the dependencies

const express = require('express');
const mongoose = require('mongoose');

const taskRoute = require("./routes/taskRoute");
// Server setup
const app = express();
const port = 4000;

// Database Connection
mongoose.connect("mongodb+srv://justineyung02:Miras1607@cluster0.mymbzfm.mongodb.net/b320-todo?retryWrites=true&w=majority", {
	useNewUrlParser: true,
	useUnifiedTopology: true
});


let db = mongoose.connection
db.on('error', console.error.bind(console, 'Connection error'));
db.once('open', () => console.log('Were connected to the cloud database'));

app.use('/tasks', taskRoute);
// server listening

app.listen(port,()=>console.log(`Server running`))