-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (29 loc) · 1.07 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
const express = require('express');
require('dotenv').config();
const methodOverride = require('method-override');
const app = express();
//Mongoose Connection
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/Infinity-Back-End', { useNewUrlParser:true});
const Review = require('./models/review');
const Module = require('./models/module');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const jwt = require('jsonwebtoken');
const port = process.env.PORT || 3000;
app.listen(port);
app.use(express.static(__dirname + '/'));
app.use(methodOverride('_method'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
var exphbs = require('express-handlebars');
//Middleware
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
require('./controllers/auth.js')(app);
require('./controllers/modules')(app);
require('./controllers/reviews')(app);
module.exports = app;
module.exports.stop = () => {
return db.close()
};