- Removed `ciTargetName` from `nx.json`. - Updated `package.json` to include new dependencies: `@types/seedrandom`, `fast-check`, `happy-dom`, and `@nestjs/schedule`. - Modified `pnpm-lock.yaml` to reflect the addition of new packages and their versions. - Improved project documentation in `PROJECT_CONTEXT.md` to clarify the use of Zod schemas and Angular framework decisions. - Introduced new Angular components and patterns in the `.agents/skills/frontend-angular` directory, including examples and reference materials for Angular 21+ features.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
HttpCode,
|
|
HttpStatus,
|
|
NotFoundException,
|
|
Post,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import {
|
|
MissionStateResponse,
|
|
MissionStateResponseSchema,
|
|
StartMissionRequestSchema,
|
|
} from '@fog-explorer/api-interfaces';
|
|
import { TwitchClaims, TwitchJwtGuard, TwitchJwtPayload } from '../auth/twitch-jwt.guard';
|
|
import { MissionStoreService } from './mission-store.service';
|
|
import { MissionsService } from './missions.service';
|
|
|
|
@Controller('missions')
|
|
@UseGuards(TwitchJwtGuard)
|
|
export class MissionsController {
|
|
constructor(
|
|
private readonly store: MissionStoreService,
|
|
private readonly missions: MissionsService
|
|
) {}
|
|
|
|
@Get('state')
|
|
async getState(
|
|
@TwitchClaims() claims: TwitchJwtPayload
|
|
): Promise<MissionStateResponse> {
|
|
const state = await this.store.getStateForChannel(claims.channel_id);
|
|
return MissionStateResponseSchema.parse(state);
|
|
}
|
|
|
|
@Post('start')
|
|
@HttpCode(HttpStatus.CREATED)
|
|
async startMission(
|
|
@TwitchClaims() claims: TwitchJwtPayload,
|
|
@Body() body: unknown
|
|
): Promise<MissionStateResponse> {
|
|
if (!claims.opaque_user_id.startsWith('U')) {
|
|
throw new NotFoundException('Anonymous viewers cannot start missions');
|
|
}
|
|
const { difficulty } = StartMissionRequestSchema.parse(body);
|
|
return this.missions.startMission(claims, difficulty);
|
|
}
|
|
}
|