feat(server): added types for saveSettings
This commit is contained in:
@@ -9,10 +9,14 @@ import wsModules from './modules'
|
||||
export const registerWebsocket = (wss: WsServer) => {
|
||||
wss.on('connection', ws => {
|
||||
ws.on('message', message => {
|
||||
consoleInfo(`received: ${message}`)
|
||||
consoleInfo(`Received: ${message}`)
|
||||
|
||||
const data = JSON.parse(message.toString())
|
||||
|
||||
wsModules.forEach(module => {
|
||||
if (data.key === module.eventName) module.cb(data.data, ws, wss)
|
||||
if (data.key === module.eventName) {
|
||||
module.cb(data.data, ws, wss)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { Server as WsServer } from 'ws'
|
||||
import { consoleInfo } from '../../helpers/errors'
|
||||
import { saveSettings, listener } from '../../main'
|
||||
import { Settings, SpotifySettings } from '../../types'
|
||||
|
||||
const eventName = 'saveSettings'
|
||||
|
||||
const cb = (data: any, _: any, __: WsServer) => {
|
||||
export interface SaveSettingsData {
|
||||
settings: Settings
|
||||
spotifySettings: SpotifySettings
|
||||
}
|
||||
|
||||
const cb = (data: SaveSettingsData, _: any, __: WsServer) => {
|
||||
const { settings, spotifySettings } = data
|
||||
saveSettings(settings)
|
||||
consoleInfo('Settings saved')
|
||||
|
||||
Reference in New Issue
Block a user