-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
35 lines (26 loc) · 1.09 KB
/
server.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
var express = require('express');
var exphbs = require('express-handlebars');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var app = express();
var PORT = process.env.PORT || 3000;
//requireing our models for syncing
var db = require("./models");
// Serve static content for the app from the "public" directory in the application directory.
app.use(express.static("public"));
app.use(methodOverride('_method'));
// Parse application
app.use(bodyParser.urlencoded({ extended: false }));
//register a Handlebars view engine
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
//require the express routes from burgers_controller.js set to variable routes
var routes = require('./controllers/controller.js');
//use the var routes (express routes) when url returns /index
app.use('/', routes);
//syncing our sequlize models and then starting our express app
db.sequelize.sync({ force: false }).then(function () {
app.listen(PORT, function () {
console.log("listenning on http://localhost:" + PORT);
});
});