18 lines
514 B
TypeScript
18 lines
514 B
TypeScript
// src/routes/api/matches/[id]/lobby/+server.ts
|
|
import { json, error } from '@sveltejs/kit';
|
|
import { moveToLobby } 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 body = await request.json().catch(() => ({}));
|
|
|
|
try {
|
|
const m = await moveToLobby(params.id, body.osuLobbyId);
|
|
return json(m);
|
|
} catch (e: any) {
|
|
error(400, e.message);
|
|
}
|
|
};
|