-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (29 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
require("dotenv").config();
const express = require("express");
const cookieparser = require("cookie-parser");
const passport = require("./server/config/passport.config");
const fileUpload = require('express-fileupload');
const userRouter = require("./server/routes/user.routes")
const videoRouter = require("./server/routes/video.routes")
//const uploadRouter = require("./server/routes/upload.routes")
const app = express();
const SERVER_PORT = process.env.PORT || 8080;
app.use(express.json());
app.use(express.static(__dirname + "/build"));
app.use(cookieparser());
app.use(passport.initialize());
// Todo maybe change it to use temp file instead of memory
// app.use(fileUpload({
// useTempFiles : true,
// tempFileDir : __dirname + '/tmp/'
// }));
app.use(fileUpload());
app.use("/api/user", userRouter)
app.use("/api/video", videoRouter)
//app.use("/api/upload", uploadRouter)
app.get("*", (req, res) => {
return res.sendFile("/build/index.html", { root: __dirname + "/" });
});
app.listen(SERVER_PORT, () => {
console.log(`Example app listening on port ${SERVER_PORT}!`);
});