Added route to get current played song
This commit is contained in:
parent
edde981b1f
commit
90d297c3b3
1 changed files with 6 additions and 0 deletions
6
app.js
6
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;
|
||||
|
|
Loading…
Reference in a new issue