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";
|
} from "./libs/Format";
|
||||||
|
|
||||||
let currentSongId = "";
|
let currentSongId = "";
|
||||||
|
let currentSong = {};
|
||||||
|
|
||||||
const pino = new Pino({
|
const pino = new Pino({
|
||||||
prettyPrint: true,
|
prettyPrint: true,
|
||||||
|
@ -41,6 +42,7 @@ app.post("/post", function (req, res, next) {
|
||||||
const newSongId = req.body.now_playing.song.id;
|
const newSongId = req.body.now_playing.song.id;
|
||||||
if (newSongId !== currentSongId) {
|
if (newSongId !== currentSongId) {
|
||||||
currentSongId = newSongId;
|
currentSongId = newSongId;
|
||||||
|
currentSong = req.body.now_playing.song;
|
||||||
fs.writeFile("./currentSongId", currentSongId, (err) => {
|
fs.writeFile("./currentSongId", currentSongId, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
req.log.error(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
|
// Gestion des erreurs
|
||||||
app.use((err, req, res, next) => {
|
app.use((err, req, res, next) => {
|
||||||
res.error = err;
|
res.error = err;
|
||||||
|
|
Loading…
Reference in a new issue