forked from Am-White/DanceTeacher_db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (50 loc) · 1.84 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
48
49
50
51
// *****************************************************************************
// Server.js - This file is the initial starting point for the Node/Express server.
//
// ******************************************************************************
// *** Dependencies
// =============================================================
require("dotenv").config();
var session = require("express-session");
var express = require("express");
var exphbs = require("express-handlebars");
var passport = require("./config/passport");
// Sets up the Express App
// =============================================================
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
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static(__dirname + "/public"));
// For Passport
app.use(
session({
secret: "keyboard cat",
resave: true,
saveUninitialized: true
})
); // session secret
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
// Handlebars
app.use(express.static("views"));
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// Routes
// =============================================================
require("./routes/html-routes.js")(app);
require("./routes/userAuthRoutes.js")(app);
require("./routes/userRoute.js")(app);
require("./routes/dance-api-routes.js")(app);
require("./routes/class-api-routes.js")(app);
require("./routes/instructor-api-routes.js")(app);
// Syncing our sequelize models and then starting our Express app
// =============================================================
db.sequelize.sync().then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});