-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (30 loc) · 1.07 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
const express = require("express");
const app = express();
const bodyParser = require('body-parser');
const apiRouter = require('./mysql/api-server')
const cors = require('cors')
const path = require("path");
const port = process.env.PORT || 5400;
const cookie_parser = require("cookie-parser");
const session = require("express-session")
const redis = require('redis')
let RedisStore = require('connect-redis')(session)
let redisClient = redis.createClient()
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "Public")));
app.use(cookie_parser());
app.use(cors())
app.use(session({
store: new RedisStore({ client: redisClient }),
secret: "cats", resave: true, saveUninitialized: true
}));
// app.use(express.static(path.join(__dirname, 'client','build')));
app.use("/api", apiRouter);
// app.use('/forms',formRoute);
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html'));
});
app.listen(port, () => {
console.log(`listining on port ${port}`);
});