From 90d297c3b3cb0475cd94fe49208a39671acfb2d7 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 2 May 2020 10:14:17 +0200 Subject: [PATCH] Added route to get current played song --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index c7aa9d6..096e822 100644 --- a/app.js +++ b/app.js @@ -12,6 +12,7 @@ import { } from "./libs/Format"; let currentSongId = ""; +let currentSong = {}; const pino = new Pino({ prettyPrint: true, @@ -41,6 +42,7 @@ app.post("/post", function (req, res, next) { const newSongId = req.body.now_playing.song.id; if (newSongId !== currentSongId) { currentSongId = newSongId; + currentSong = req.body.now_playing.song; fs.writeFile("./currentSongId", currentSongId, (err) => { if (err) { req.log.error(err); @@ -58,6 +60,10 @@ app.post("/post", function (req, res, next) { } }); +app.get("/current", function (req, res, next) { + formatResponse(req, res, next, null, currentSong); +}); + // Gestion des erreurs app.use((err, req, res, next) => { res.error = err;