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 getUserFavorites from './getUserFavorites'
import getQueue from './getQueue'
import spotifyStatus from './spotifyStatus'
export default [
albumSearch,
@ -35,5 +36,6 @@ export default [
getUserPlaylists,
getUserSpotifyPlaylists,
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
import { Deezer } from 'deezer-js'
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()
let update: any = null
@ -27,7 +27,8 @@ router.get('/connect', async (req, res) => {
update,
autologin: !dz.logged_in,
currentUser: dz.current_user,
deezerAvailable: await isDeezerAvailable()
deezerAvailable: await isDeezerAvailable(),
spotifyEnabled: plugins.spotify.enabled
}
const queue = getQueue()