FINALLY, Beautiful connection types!

This commit is contained in:
Eclypsed
2024-02-23 00:53:54 -05:00
parent c2236ab8ac
commit c7b9b214b7
16 changed files with 200 additions and 214 deletions

View File

@@ -1,9 +1,21 @@
import { Connections } from '$lib/server/users'
import { Jellyfin, YouTubeMusic } from '$lib/services'
import type { RequestHandler } from '@sveltejs/kit'
export const GET: RequestHandler = async ({ params }) => {
const userId = params.userId!
const connections = Connections.getUserConnections(userId)
for (const connection of connections) {
switch (connection.type) {
case 'jellyfin':
connection.service = await Jellyfin.fetchSerivceInfo(connection.service.userId, connection.service.urlOrigin, connection.tokens.accessToken)
break
case 'youtube-music':
connection.service = await YouTubeMusic.fetchServiceInfo(connection.service.userId, connection.tokens.accessToken)
break
}
}
return Response.json({ connections })
}