feat(server): added spotifyStatus endpoint to get spotify plugin status; feat(server): added plugin information on connect endpoint

This commit is contained in:
Roberto Tonino 2021-08-11 15:25:02 +02:00
parent 94f79b4a8c
commit 43568713b6
3 changed files with 18 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import getUserPlaylists from './getUserPlaylists'
import getUserSpotifyPlaylists from './getUserSpotifyPlaylists' import getUserSpotifyPlaylists from './getUserSpotifyPlaylists'
import getUserFavorites from './getUserFavorites' import getUserFavorites from './getUserFavorites'
import getQueue from './getQueue' import getQueue from './getQueue'
import spotifyStatus from './spotifyStatus'
export default [ export default [
albumSearch, albumSearch,
@ -35,5 +36,6 @@ export default [
getUserPlaylists, getUserPlaylists,
getUserSpotifyPlaylists, getUserSpotifyPlaylists,
getUserFavorites, getUserFavorites,
getQueue getQueue,
spotifyStatus
] ]

View File

@ -0,0 +1,12 @@
import { ApiHandler } from '../../../types'
import { plugins } from '../../../main'
const path: ApiHandler['path'] = '/spotifyStatus'
const handler: ApiHandler['handler'] = (_, res) => {
res.send({ spotifyEnabled: plugins.spotify.enabled })
}
const apiHandler: ApiHandler = { path, handler }
export default apiHandler

View File

@ -3,7 +3,7 @@ import express from 'express'
// @ts-expect-error // @ts-expect-error
import { Deezer } from 'deezer-js' import { Deezer } from 'deezer-js'
import { GUI_PACKAGE } from '../helpers/paths' import { GUI_PACKAGE } from '../helpers/paths'
import { sessionDZ, getQueue, deemixVersion, isDeezerAvailable } from '../main' import { sessionDZ, getQueue, deemixVersion, isDeezerAvailable, plugins } from '../main'
const router = express.Router() const router = express.Router()
let update: any = null let update: any = null
@ -27,7 +27,8 @@ router.get('/connect', async (req, res) => {
update, update,
autologin: !dz.logged_in, autologin: !dz.logged_in,
currentUser: dz.current_user, currentUser: dz.current_user,
deezerAvailable: await isDeezerAvailable() deezerAvailable: await isDeezerAvailable(),
spotifyEnabled: plugins.spotify.enabled
} }
const queue = getQueue() const queue = getQueue()