Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulpoonia29 committed May 12, 2024
1 parent 50e6bb4 commit 0335fc0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import express from "express";
import axios from "axios";
import bodyParser from "body-parser";
import cors from "cors";
import cors from "cors";

const cache = new Map();

const app = express();
const port = 3030;
const PORT = 3030;
let name = "";

app.use(bodyParser.urlencoded({ extended: true }));
Expand Down Expand Up @@ -34,11 +34,15 @@ app.get("/search", async (req, res) => {
response.data.data.results.length > 0
) {
const musicArray = response.data.data.results.map((result) => ({
url: result.downloadUrl[4]?.url||'',
name: result.name||'',
year: result.year||'',
artist: result.artists.primary[0]?.name.replace(/&/g, '&') || "",
img: result.image[2]?.url||'',
url: result.downloadUrl[4]?.url || "",
name: result.name || "",
year: result.year || "",
artist:
result.artists.primary[0]?.name.replace(
/&/g,
"&"
) || "",
img: result.image[2]?.url || "",
}));
cache.set(name, musicArray);
res.json(musicArray);
Expand All @@ -54,8 +58,6 @@ app.get("/search", async (req, res) => {
}
});



app.listen(port, () => {
app.listen(PORT, () => {
console.log(`Server is running on port ${port}`);
});

0 comments on commit 0335fc0

Please sign in to comment.