-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (30 loc) · 1.11 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
const express = require('express');
const mongoose = require('mongoose');
const path = require('path');
const cors = require('cors');
require('dotenv').config();
const indexRouter = require('./routes/index');
const authRouter = require('./routes/auth');
const verifyRouter = require('./routes/verify');
const db = process.env.MONGODB_URL;
const app = express();
const port = process.env.PORT || 3000;
const server = app.listen(port, (err) => {
console.log(`API listening on ${port}!`);
if (err) throw err;
});
mongoose.connect(db, { useUnifiedTopology: true, useNewUrlParser: true })
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));
mongoose.set('useFindAndModify', false);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.json({ limit: '50mb', extended: true }));
app.use(express.urlencoded({ limit: '50mb', extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(cors());
app.use('/', indexRouter);
app.use('/auth', authRouter);
app.use('/verify', verifyRouter);
module.exports = app;