deemixer/server/src/websocket/modules/saveSettings.ts
2022-02-28 14:58:25 +01:00

21 lines
620 B
TypeScript

import { Server as WsServer } from 'ws'
import { logger } from '../../helpers/logger'
import { DeemixApp } from '../../app'
import { Settings, SpotifySettings } from '../../types'
const eventName = 'saveSettings'
export interface SaveSettingsData {
settings: Settings
spotifySettings: SpotifySettings
}
const cb = (data: SaveSettingsData, _: any, __: WsServer, deemix: DeemixApp) => {
const { settings, spotifySettings } = data
deemix.saveSettings(settings, spotifySettings)
logger.info('Settings saved')
deemix.listener.send('updateSettings', { settings, spotifySettings })
}
export default { eventName, cb }