Skip to content

Commit

Permalink
BAND ROUTE
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbiDev committed Jun 16, 2024
1 parent 18734c7 commit 48341ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
11 changes: 10 additions & 1 deletion api/data/songs/thunder.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
"duration": "3:07",
"album": "Evolve",
"genre": "Pop-rock",
"lyrics": "Just a young gun with a quick fuse\n I was uptight, wanna let loose\nI was dreaming of bigger things And wanna leave my own life behind Not a yes sir not a follower Fit the box fit the mold Have a seat in the foyer take a number I was lightning before the thunder Thunder thunder Thunder thun thun thunder Thunder thunder Thunder thun thun thunder",
"lyrics": [
"Just a young gun with a quick fuse\nI was uptight, wanna let loose\nI was dreaming of bigger things\nAnd wanna leave my own life behind\nNot a 'Yes, sir,' not a follower\nFit the box, fit the mold\nHave a seat in the foyer, take a number\nI was lightning before the thunder\nThunder, thunder\nThunder, thun—\nThunder, th-th-thunder, thunder\nThunder, thunder, thun—\nThunder, th-th-thunder, thunder",
"Thunder, feel the thunder (Thunder, thunder, thun—)\nLightning, then the thunder (Thunder, th-th-thunder, thunder)\nThunder, feel the thunder (Thunder, thunder, thun—, thun—)\nLightning, then the thunder, thunder, thunder (Th-th-thunder)\nThunder (Thun—, thun—)",
"Kids were laughing in my classes\nWhile I was scheming for the masses\nWho do you think you are?\nDreaming 'bout being a big star\nThey say: 'You're basic,' they say: 'You're easy'\nYou're always riding in the backseat\nNow I'm smiling from the stage\nWhile you were clapping in the nosebleeds",
"Thunder, thunder\nThunder, thun—\nThunder, th-th-thunder, thunder\nThunder, thunder, thun—\nThunder, th-th-thunder, thunder",
"Thunder, feel the thunder (Thunder, thunder, thun—)\nLightning, then the thunder (Thunder, th-th-thunder, thunder)\nThunder, feel the thunder (Thunder, thunder, thun—, thun—)\nLightning, then the thunder, thunder, thunder (Th-th-thunder)\nThunder (Thun—, thun—)",
"Thunder, feel the thunder\nLightning, then the thunder, thunder",
"Thunder, feel the thunder (Thunder, thunder, thun—)\nLightning, then the thunder, thunder (Thunder, th-th-thunder, thunder)\nThunder, feel the thunder (Thunder, thunder, thun—, thun—)\nLightning, then the thunder, thunder (Th-th-thunder)\nThunder, feel the thunder (Thunder, thunder, thun—)\n(Never give up, never give up)\nLightning, then the thunder, thunder (Thunder, th-th-thunder, thunder)\n(Never give up on your dreams)\nThunder, feel the thunder (Thunder, thunder, thun—, thun—)\n(Never give up, never give up)\nLightning, then the thunder, thunder (Th-th-thunder)\n(Never give up on your dreams)",
"Thunder, thunder, thun—\nThunder, th-th-thunder, thunder\nThunder, thunder, thun—\nThunder, th-th-thunder, thunder\n(Woah-oh-ohh)\nThunder, thunder, thun—\nThunder, th-th-thunder, thunder\n(Woah-oh-ohh)\nThunder, thunder, thun—\nThunder, th-th-thunder, thunder"
],
"released": "April 27, 2017"
}
32 changes: 23 additions & 9 deletions api/routes/bandRoutes.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
// Imports
import { fileURLToPath } from 'url';
import { fileURLToPath } from 'url'
import { Success, Error } from '../util/ResponseHandler.js'
import path, { dirname } from 'path';
import express from 'express';
import fs from 'fs';
import path, { dirname } from 'path'
import express from 'express'
import fs from 'fs'

const router = express.Router();
const router = express.Router()

// File Handling
const __dirname = dirname(fileURLToPath(import.meta.url));
const FilePath = path.resolve(__dirname, '../data/band.json');
const __dirname = dirname(fileURLToPath(import.meta.url))
const FilePath = path.resolve(__dirname, '../data/band.json')

// Middleware to read JSON file
function readFile() {
return JSON.parse(fs.readFileSync(FilePath, 'utf8'));
return JSON.parse(fs.readFileSync(FilePath, 'utf8'))
}

// GET /albums - Get all albums
router.get('/', (req, res) => {
try {
const band = readFile();
const band = readFile()
Success(res, 200, band)
} catch (err) {
Error(res, 404, "fu")
}
});

// GET /albums - Get all albums
router.get('/:type', (req, res) => {

const type = req.params.type

try {
const band = readFile()
const data = band[`${type}`]
Success(res, 200, data)
} catch (err) {
Error(res, 404, "fu")
}
});

export default router;

0 comments on commit 48341ba

Please sign in to comment.