21 lines
594 B
TypeScript
21 lines
594 B
TypeScript
// src/routes/api/matches/[id]/rolling/+server.ts
|
|
import { json, error } from '@sveltejs/kit';
|
|
import { moveToRolling } from '$lib/server/match/engine';
|
|
import { requirePermission, GlobalPermission } from '$lib/server/permissions';
|
|
import type { RequestHandler } from './$types';
|
|
|
|
export const POST: RequestHandler = async ({ params, locals }) => {
|
|
requirePermission(
|
|
locals,
|
|
GlobalPermission.MATCH_REFEREE,
|
|
'Only referees or admins can move matches to rolling'
|
|
);
|
|
|
|
try {
|
|
const m = await moveToRolling(params.id);
|
|
return json(m);
|
|
} catch (e: any) {
|
|
error(400, e.message);
|
|
}
|
|
};
|