23 lines
634 B
TypeScript
23 lines
634 B
TypeScript
import { PlayerClient } from '$lib/proto/player.client';
|
|
import { fail } from '@sveltejs/kit';
|
|
import { protoTransport } from '../../../hooks.server';
|
|
import type { Actions } from './$types';
|
|
import { serializable } from '$lib/proto';
|
|
import type { PlayTrackResponse } from '$lib/proto/player';
|
|
|
|
export const actions = {
|
|
play: async ({ params }) => {
|
|
const client = new PlayerClient(protoTransport);
|
|
|
|
const response = await client.playTrack({
|
|
hash: params.hash
|
|
});
|
|
|
|
if (response.response.track === undefined) {
|
|
return fail(500);
|
|
}
|
|
|
|
return serializable<PlayTrackResponse>(response.response);
|
|
}
|
|
} satisfies Actions;
|