-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
74 lines (59 loc) · 2.4 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
62
63
64
65
66
67
68
69
70
71
72
73
74
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
const path = require("path");
const dotenv = require("dotenv");
const createSeratoLiveReport = require("./scripts/Serato/createSeratoLiveReport");
const createSeratoReport = require("./scripts/Serato/createSeratoReport");
const createTraktorReport = require("./scripts/Traktor/createTraktorReport");
const createRekordboxReport = require("./scripts/Rekordbox/createRekordboxReport");
// const createEngineReport = require("./scripts/Engine/createEngineReport");
const createSiteStatsReport = require("./scripts/SiteStats/createSiteStatsReport")
const { addNewPlaylist, getPlaylists, deletePlaylist } = require("./firebase");
dotenv.config();
const PORT = process.env.PORT || 5000;
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "client/build")));
app.post("/liveplaylist", async (req, res) => {
const seratoLivePlaylistReport = await createSeratoLiveReport(req.body.url);
res.send(seratoLivePlaylistReport);
});
app.post("/sendSeratoFile", async (req, res) => {
const userReport = await createSeratoReport(req.body);
// await addNewPlaylist(userReport)
res.send(userReport);
});
app.post("/sendTraktorFile", async (req, res) => {
const userReport = await createTraktorReport(req.body);
res.send(userReport);
});
app.post("/sendRekordboxFile", async (req, res) => {
const userReport = await createRekordboxReport(req.body);
res.send(userReport);
});
app.post("/getSiteStats", async (req, res) => {
await createSiteStatsReport().then(data => res.send(data))
});
app.post("/getPlaylists", async (req, res) => {
// createEngineReport();
const userPlaylists = await getPlaylists();
console.log(userPlaylists)
res.send(userPlaylists);
});
app.post("/addPlaylist", async (req, res) => {
const newPlaylist = await addNewPlaylist(req.body);
res.send(newPlaylist);
});
app.post("/deletePlaylist", async (req, res) => {
const deletedPlaylist = await deletePlaylist(req.body.file_id);
res.send(deletedPlaylist)
});
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname + "/client/build/index.html"));
});
app.listen(PORT, () => {
console.log(`Crate Stats Server is listening on port: ${PORT}`);
});