refactor: use track instead of song
This commit is contained in:
22
src/routes/tracks/[hash]/+page.server.ts
Normal file
22
src/routes/tracks/[hash]/+page.server.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user