feat(server): added types for saveSettings
This commit is contained in:
parent
669854f799
commit
335819b2bb
@ -10,3 +10,89 @@ export interface ApiHandler {
|
|||||||
path: string
|
path: string
|
||||||
handler: RequestHandler<any, any, any, any>
|
handler: RequestHandler<any, any, any, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Tags {
|
||||||
|
title: boolean
|
||||||
|
artist: boolean
|
||||||
|
album: boolean
|
||||||
|
cover: boolean
|
||||||
|
trackNumber: boolean
|
||||||
|
trackTotal: boolean
|
||||||
|
discNumber: boolean
|
||||||
|
discTotal: boolean
|
||||||
|
albumArtist: boolean
|
||||||
|
genre: boolean
|
||||||
|
year: boolean
|
||||||
|
date: boolean
|
||||||
|
explicit: boolean
|
||||||
|
isrc: boolean
|
||||||
|
length: boolean
|
||||||
|
barcode: boolean
|
||||||
|
bpm: boolean
|
||||||
|
replayGain: boolean
|
||||||
|
label: boolean
|
||||||
|
lyrics: boolean
|
||||||
|
syncedLyrics: boolean
|
||||||
|
copyright: boolean
|
||||||
|
composer: boolean
|
||||||
|
involvedPeople: boolean
|
||||||
|
source: boolean
|
||||||
|
savePlaylistAsCompilation: boolean
|
||||||
|
useNullSeparator: boolean
|
||||||
|
saveID3v1: boolean
|
||||||
|
multiArtistSeparator: string
|
||||||
|
singleAlbumArtist: boolean
|
||||||
|
coverDescriptionUTF8: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Settings {
|
||||||
|
downloadLocation: string
|
||||||
|
tracknameTemplate: string
|
||||||
|
albumTracknameTemplate: string
|
||||||
|
playlistTracknameTemplate: string
|
||||||
|
createPlaylistFolder: boolean
|
||||||
|
playlistNameTemplate: string
|
||||||
|
createArtistFolder: boolean
|
||||||
|
artistNameTemplate: string
|
||||||
|
createAlbumFolder: boolean
|
||||||
|
albumNameTemplate: string
|
||||||
|
createCDFolder: boolean
|
||||||
|
createStructurePlaylist: boolean
|
||||||
|
createSingleFolder: boolean
|
||||||
|
padTracks: boolean
|
||||||
|
paddingSize: string
|
||||||
|
illegalCharacterReplacer: string
|
||||||
|
queueConcurrency: number
|
||||||
|
maxBitrate: string
|
||||||
|
fallbackBitrate: boolean
|
||||||
|
fallbackSearch: boolean
|
||||||
|
logErrors: boolean
|
||||||
|
logSearched: boolean
|
||||||
|
saveDownloadQueue: boolean
|
||||||
|
overwriteFile: string
|
||||||
|
createM3U8File: boolean
|
||||||
|
playlistFilenameTemplate: string
|
||||||
|
syncedLyrics: boolean
|
||||||
|
embeddedArtworkSize: number
|
||||||
|
embeddedArtworkPNG: boolean
|
||||||
|
localArtworkSize: number
|
||||||
|
localArtworkFormat: string
|
||||||
|
saveArtwork: boolean
|
||||||
|
coverImageTemplate: string
|
||||||
|
saveArtworkArtist: boolean
|
||||||
|
artistImageTemplate: string
|
||||||
|
jpegImageQuality: number
|
||||||
|
dateFormat: string
|
||||||
|
albumVariousArtists: boolean
|
||||||
|
removeAlbumVersion: boolean
|
||||||
|
removeDuplicateArtists: boolean
|
||||||
|
tagsLanguage: string
|
||||||
|
featuredToTitle: string
|
||||||
|
titleCasing: string
|
||||||
|
artistCasing: string
|
||||||
|
executeCommand: string
|
||||||
|
tags: Tags
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
export interface SpotifySettings {}
|
||||||
|
@ -9,10 +9,14 @@ import wsModules from './modules'
|
|||||||
export const registerWebsocket = (wss: WsServer) => {
|
export const registerWebsocket = (wss: WsServer) => {
|
||||||
wss.on('connection', ws => {
|
wss.on('connection', ws => {
|
||||||
ws.on('message', message => {
|
ws.on('message', message => {
|
||||||
consoleInfo(`received: ${message}`)
|
consoleInfo(`Received: ${message}`)
|
||||||
|
|
||||||
const data = JSON.parse(message.toString())
|
const data = JSON.parse(message.toString())
|
||||||
|
|
||||||
wsModules.forEach(module => {
|
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 { Server as WsServer } from 'ws'
|
||||||
import { consoleInfo } from '../../helpers/errors'
|
import { consoleInfo } from '../../helpers/errors'
|
||||||
import { saveSettings, listener } from '../../main'
|
import { saveSettings, listener } from '../../main'
|
||||||
|
import { Settings, SpotifySettings } from '../../types'
|
||||||
|
|
||||||
const eventName = 'saveSettings'
|
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
|
const { settings, spotifySettings } = data
|
||||||
saveSettings(settings)
|
saveSettings(settings)
|
||||||
consoleInfo('Settings saved')
|
consoleInfo('Settings saved')
|
||||||
|
Loading…
Reference in New Issue
Block a user