-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
61 lines (50 loc) · 1.78 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
52
53
54
55
56
57
58
59
60
61
var express = require("express");
var bodyParser = require("body-parser");
var methodOverride = require("method-override");
var passport = require("passport");
var session = require('express-session');
var bcrypt = require("bcrypt-nodejs");
var path = require("path");
require('./passport.js');
// Set up the Express App
// ======================
var app = express();
var PORT = process.env.PORT || 3001;
// Requiring our models for syncing
// ================================
var db = require("./models");
// Set up the Express app to handle data parsing
// =============================================
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: "application/vmd.api+json"}));
// Set up session
// ==============
app.use(session({secret: "SECRET" , resave: false, saveUninitialized: false }));
app.use(passport.initialize());
app.use(passport.session());
// Static Directory
// ================
app.use(express.static("client/build"));
// Routes
// ======
var index = require("./controller/index.routes");
var api = require("./controller/api.routes");
var account = require("./controller/account.routes");
var customer = require("./controller/custController");
var sale = require("./controller/salesController");
var schedule = require("./controller/calController");
app.use("/", index);
app.use("/api", api);
app.use("/account", account);
app.use("/customers", customer);
app.use("/sales", sale);
app.use("/schedule", schedule);
// Syncing our sequelize models and then starting our Express app
// =============================================================
app.listen(PORT, function () {
console.log("App is listening on PORT " + PORT);
db.sequelize.sync({ force: false });
});
module.exports = app;