Files
Lazuli/src/routes/api/users/[userId]/connections/+server.ts

22 lines
848 B
TypeScript
Raw Normal View History

2024-02-01 18:10:15 -05:00
import { Connections } from '$lib/server/users'
2024-02-23 00:53:54 -05:00
import { Jellyfin, YouTubeMusic } from '$lib/services'
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
}