osu match playing
This commit is contained in:
19
src/routes/api/matches/[id]/pick/+server.ts
Normal file
19
src/routes/api/matches/[id]/pick/+server.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { pickMap } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
if (!locals.user) error(401, 'Not logged in');
|
||||
|
||||
const { participantId, mappoolSlotId } = await request.json();
|
||||
if (!participantId || !mappoolSlotId) {
|
||||
error(400, 'participantId and mappoolSlotId required');
|
||||
}
|
||||
|
||||
try {
|
||||
const game = await pickMap(params.id, participantId, mappoolSlotId);
|
||||
return json(game);
|
||||
} catch (e) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user