Something went wrong. Try again.
Synapse is a study workspace. Organize courses read and annotate the material, train with generated exercises and watch your progress forked from denishovart.com/synapse
Something went wrong. Try again.
1234567891011121314151617181920import { Body, Controller, Post } from '@nestjs/common';import { Throttle } from '@nestjs/throttler';import { ExercisesService } from '../application/exercises.service';import { CurrentUser } from '../auth/auth.decorators';import type { PublicUser } from '../domain/models';import { GenerateExercisesDto } from './dto/misc.dto';
const ownerOf = (u: PublicUser | undefined): string | null => u?.id ?? null;
@Controller('api/exercises')export class ExercisesController { constructor(private readonly service: ExercisesService) {}
@Throttle({ default: { ttl: 60_000, limit: 30 } }) @Post('generate') generate(@Body() dto: GenerateExercisesDto, @CurrentUser() user?: PublicUser) { return this.service.generate(dto, ownerOf(user)); }}