Refactor API and enhance Angular integration
- 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.
This commit is contained in:
48
apps/api/src/app/missions/missions.controller.ts
Normal file
48
apps/api/src/app/missions/missions.controller.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user