-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (45 loc) · 1.43 KB
/
index.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
const connect = require("./connectdb");
connect();
const {
getSongs,
addSong,
searchSongs,
createPlaylist,
addSongToPlaylist,
addSongToHistory,
recommendation,
updateSong,
deleteSong,
getPlaylistSongs,
getUserPlaylist,
getUserHistory,
} = require("./controllers/songs");
const {
app,
register,
login,
logout,
checkLoginStatus,
} = require("./controllers/authentication");
const isAdmin = require("./middleware/isAdmin");
const upload = require("./middleware/multer");
const isAuthenticated = require("./middleware/isAuthenticated");
app.post("/register", register);
app.post("/login", login);
app.post("/logout", logout);
app.get("/checkLoginStatus", checkLoginStatus);
app.get("/songs", getSongs);
app.post("/songs", isAdmin, upload, addSong);
app.get("/search", searchSongs);
app.post("/createPlaylist", isAuthenticated, createPlaylist);
app.post("/addSongToPlaylist", isAuthenticated, addSongToPlaylist);
app.get("/getUserPlaylist", isAuthenticated, getUserPlaylist);
app.post("/getPlaylistSongs", isAuthenticated, getPlaylistSongs);
app.post("/getUserHistory", isAuthenticated, getUserHistory);
app.post("/addSongToHistory", isAuthenticated, addSongToHistory);
app.get("/recommendedsongs", isAuthenticated, recommendation);
app.post("/updateSong", isAdmin, updateSong);
app.post("/deleteSong", isAdmin, deleteSong);
app.listen(process.env.PORT || 5000, () => {
console.log("Server Started.......");
});