2024-02-01 18:10:15 -05:00
|
|
|
import { Connections } from '$lib/server/users'
|
2024-02-25 00:33:34 -05:00
|
|
|
import { Jellyfin } from '$lib/services'
|
|
|
|
|
import { YouTubeMusic } from '$lib/service-managers/youtube-music'
|
2024-01-30 12:27:37 -05:00
|
|
|
import type { RequestHandler } from '@sveltejs/kit'
|
|
|
|
|
|
|
|
|
|
export const GET: RequestHandler = async ({ params }) => {
|
2024-02-18 00:01:54 -05:00
|
|
|
const userId = params.userId!
|
2024-01-30 12:27:37 -05:00
|
|
|
|
|
|
|
|
const connections = Connections.getUserConnections(userId)
|
2024-02-23 00:53:54 -05:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-18 00:01:54 -05:00
|
|
|
return Response.json({ connections })
|
2024-01-30 12:27:37 -05:00
|
|
|
}
|