-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
47 lines (37 loc) · 1.27 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
36
37
38
39
40
41
42
43
44
45
46
47
var express = require("express");
var bodyParser = require("body-parser");
var fileUpload = require('express-fileupload');
var session = require("express-session");
var cookies = require("cookie-parser");
var app = express();
var PORT = process.env.PORT || 8080;
// Requiring our models for syncing
var db = require("./models");
// Sets up the Express app to handle data parsing
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse application/json
app.use(bodyParser.json());
//express validator will come after bodyParser
app.use(cookies());
app.use(session({
secret: "whateverwewant",
resave: false,
saveUninitialized: true,
cookie: {secure: "auto", maxAge: 999999}
}));
// Static directory
app.use(express.static("public"));
app.use(fileUpload());
// Routes
// =============================================================
require("./routes/api-routes.js")(app);
require("./routes/html-routes.js")(app);
require("./routes/category-api-routes.js")(app);
// Syncing our sequelize models and then starting our Express app
// =============================================================
db.sequelize.sync({ force: false }).then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});