-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (27 loc) · 1007 Bytes
/
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
36
var express = require("express");
var exphbs = require("express-handlebars");
var path = require('path');
var bodyParser = require("body-parser");
var favicon = require('serve-favicon');
var methodOverride = require("method-override");
var errorHandler = require("errorhandler");
var db = require("./models");
var app = express();
var PORT = process.env.PORT || 3000;
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(methodOverride("_method"));
app.use(express.static(__dirname + "/public"));
app.use(favicon(path.join(__dirname + "/public/assets/", "favicon.ico")))
var routes = require("./controllers/cakesController");
app.use("/", routes);
app.use("/update", routes);
app.use("/create", routes);
app.use(errorHandler());
db.sequelize.sync().then(function() {
app.listen(PORT, function() {
console.log("Listening on port:%s", PORT);
});
});