-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (29 loc) · 1.15 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
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
var exphbs = require("express-handlebars");
var passport = require("passport");
var session = require("express-session");
var env = require("dotenv").load();
var helpers = require("handlebars-helpers")();
var PORT = process.env.PORT || 3000;
var db = require("./models");
// Passport authentication
app.use(session({ secret: "codingbootcamp", resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session()); // persistent login
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static("public"));
require("./routes/html-routes.js")(app);
require("./routes/api-routes.js")(app);
var authRoute = require("./routes/auth-routes.js")(app, passport);
require("./config/passport.js")(passport, db.User);
// Coonects Sequelize to models directory
db.sequelize.sync().then(function () {
app.listen(PORT, function () {
console.log("Red Carpet is now listening on PORT " + PORT);
});
});