-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
52 lines (38 loc) · 1.04 KB
/
server.js
File metadata and controls
52 lines (38 loc) · 1.04 KB
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
// ================
// Dependencies
// ================
const express = require('express');
const Cors = require('cors')
const passport = require('passport');
const helmet = require('helmet');
const db = require("./models");
const bodyParser = require('body-parser')
const app = express();
require('dotenv').config();
// ================
// Static Directory
// ================
app.use(express.static(--__dirname + '/public'));
// ================
// Data Parsing
// ================
app.use(express.urlencoded({ extended: true}));
app.use(express.json());
require("./auth/userAuth.js");
app.use(helmet());
app.use(passport.initialize());
// CORS requests
app.use(Cors({
origin:["http://localhost:3000"],
}))
const allRoutes = require('./controllers');
app.use('/', allRoutes);
var PORT = process.env.PORT || 3030;
// ================
// Sequelize sync and start server
// ================
db.sequelize.sync({ force: false }).then(function() {
app.listen(PORT, function() {
console.log("Server running on PORT " + PORT);
});
});