-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (38 loc) · 1.33 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const express = require('express');
const mongoose = require('mongoose');
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
//const Task = require('./models/task');
const mainRoutes = require('./routes/mainRoutes');
const authRoutes = require('./routes/authRoutes');
const userRoutes = require('./routes/userRoutes');
const userMiddleware = require('./middleware/authMiddleware');
const taskRoutes = require('./routes/taskRoutes');
const app = express();
/* middleware */
app.use(express.static('public'));
app.use(express.urlencoded({ extended: true }));
app.use(morgan('dev'));
app.use(express.json());
app.use(cookieParser());
// view engine
app.set('view engine', 'ejs');
/* MongoDB and mongoose */
const dbURI = 'mongodb+srv://stige:stige@stige-week7-mogodb-basi.cttbz.mongodb.net/Dronacharyian?retryWrites=true&w=majority';
const port = process.env.PORT || 800;
mongoose.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true })
.then((result) => {
//console.log("result: of DBURI:- ", result);
app.listen(port);
console.log('listing on port:', port);
})
.catch(err => console.log(err));
/* Routes */
app.get('/', (req, res) => {
res.redirect('/homepage');
});
app.use(mainRoutes);
app.use(authRoutes);
app.use(userRoutes);
app.use('/tasks', taskRoutes);
// this is latest edit to check..