-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (33 loc) · 1.12 KB
/
app.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
import express from "express";
// require("dotenv/config")
import dotenv from "dotenv"
import cors from "cors"
import mongoose from "mongoose"
const app = express();
dotenv.config();
app.use(cors({origin: true}));
app.use(express.json());
app.get("/", (req, res) =>{
return res.json("Welcome to Music Web Server Side....😍😍😍!!")
})
// user authentication routes
import userRoute from "./src/routes/auth.js"
app.use("/api/users/", userRoute);
// Artist links
import artistsRoute from "./src/routes/artists.js"
app.use("/api/artists/", artistsRoute);
// Album links
import albumRoute from"./src/routes/albums.js"
app.use("/api/albums/",albumRoute);
// Songs links
import songRoute from "./src/routes/songs.js"
app.use("/api/songs/", songRoute);
// If any depreciation warning add depreciation options
mongoose.connect(process.env.DB_URL,{useNewUrlParser: true});
mongoose.connection
.once("open",() => console.log("🎉🎉🧬..MongoDB is Connected..🧬🎉🎉"))
.on("error",(error)=>{
console.log(`ERROR : ${error}`);
})
const PORT = 8000;
app.listen(PORT, () => console.log(`App is Listening to port ${PORT}`));