mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
- Add WebSocket-based sync room for real-time music playback sync. - Expand music exploration search to include albums and artists. - Adjust track and release data fetching and deletion on server. - Enhance DASH segmentation job with codec overrides and MPD updates. - Update music service configuration for websockets and middlewares. - Make minor UI adjustments to the search component.
66 lines
1.4 KiB
JavaScript
Executable File
66 lines
1.4 KiB
JavaScript
Executable File
import { Server } from "linebridge"
|
|
|
|
import DbManager from "@shared-classes/DbManager"
|
|
import SSEManager from "@shared-classes/SSEManager"
|
|
import RedisClient from "@shared-classes/RedisClient"
|
|
|
|
import SharedMiddlewares from "@shared-middlewares"
|
|
import LimitsClass from "@shared-classes/Limits"
|
|
|
|
import InjectedAuth from "@shared-lib/injectedAuth"
|
|
|
|
export default class API extends Server {
|
|
static refName = "music"
|
|
static listenPort = process.env.HTTP_LISTEN_PORT ?? 3003
|
|
|
|
static websockets = {
|
|
enabled: true,
|
|
path: "/music",
|
|
}
|
|
|
|
static bypassCors = true
|
|
|
|
static useMiddlewares = ["logs"]
|
|
|
|
middlewares = {
|
|
...SharedMiddlewares,
|
|
}
|
|
|
|
contexts = {
|
|
db: new DbManager(),
|
|
SSEManager: new SSEManager(),
|
|
redis: RedisClient(),
|
|
}
|
|
|
|
handleWsUpgrade = async (context, token, res) => {
|
|
if (!token) {
|
|
return res.upgrade(context)
|
|
}
|
|
|
|
context = await InjectedAuth(context, token, res).catch(() => {
|
|
res.close(401, "Failed to verify auth token")
|
|
return false
|
|
})
|
|
|
|
if (!context || !context.user) {
|
|
res.close(401, "Unauthorized or missing auth token")
|
|
return false
|
|
}
|
|
|
|
return res.upgrade(context)
|
|
}
|
|
|
|
async onInitialize() {
|
|
global.sse = this.contexts.SSEManager
|
|
global.redis = this.contexts.redis.client
|
|
global.syncRoomLyrics = new Map()
|
|
|
|
await this.contexts.db.initialize()
|
|
await this.contexts.redis.initialize()
|
|
|
|
this.contexts.limits = await LimitsClass.get()
|
|
}
|
|
}
|
|
|
|
Boot(API)
|