-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (34 loc) · 1.14 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
"use strict";
//call the packages that we need
var express = require('express');
var app = express();
var router = require('./routes')
var bodyParser = require('body-parser');
var fs = require('fs');
var path = require('path');
var validator = require('express-validator');
var mongoose = require('mongoose');
var hbs = require('express-handlebars')({
defaultLayout: 'main',
extname: '.hbs'
});
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.engine('hbs', hbs);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
// Now I am registering the routes. All routes will be prefixed with /api
app.use('/api', router);
var port = process.env.PORT || 8080; //setting our port to run locally first!!!!!!!!!!!!!!!!!!!!!
mongoose.connect(process.env.MONGODB_URI);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(validator());
app.use(express.static(path.join(__dirname, 'public')));
var routes = require('./routes');
app.use('/', routes)
app.listen(process.env.PORT || 8080);