1 import { server } from '../../lib/server';
2 import { Static, Type } from '@sinclair/typebox';
3 import { prisma } from '../../lib/db';
4 import { ForbiddenError } from '../../lib/http-errors';
6 const FightStartInput = Type.Object({
8 playerId: Type.String(),
13 type FightStartInputType = Static<typeof FightStartInput>;
15 export type FightStartType = {
19 export const startFight = server.post<FightStartInputType, FightStartType>('/v1/accounts/:playerId/fight/:fightId', {
20 schema: FightStartInput,
24 const { playerId } = req.params;
27 const res = await prisma.fight.update({
29 id: req.params.fightId
37 throw new ForbiddenError('You can not start a fight with a monster that does not exist');