chore: initial commit — monorepo ReadaBook (API NestJS, web PWA, Docker)
This commit is contained in:
31
apps/api/src/progress/progress.controller.ts
Normal file
31
apps/api/src/progress/progress.controller.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Body, Controller, Get, Param, Put, UseGuards } from "@nestjs/common";
|
||||
import { UpdateProgressDto, UpdateProgressSchema } from "@readabook/shared";
|
||||
import { AuthGuard } from "../auth/auth.guard.js";
|
||||
import { CurrentUser, CurrentUserParam } from "../auth/current-user.js";
|
||||
import { ZodValidationPipe } from "../common/zod-validation.pipe.js";
|
||||
import { ProgressService } from "./progress.service.js";
|
||||
|
||||
@Controller("progress")
|
||||
@UseGuards(AuthGuard)
|
||||
export class ProgressController {
|
||||
constructor(private readonly progress: ProgressService) {}
|
||||
|
||||
@Get("continue")
|
||||
continue(@CurrentUserParam() user: CurrentUser) {
|
||||
return this.progress.continueReading(user.id);
|
||||
}
|
||||
|
||||
@Get(":bookId")
|
||||
get(@CurrentUserParam() user: CurrentUser, @Param("bookId") bookId: string) {
|
||||
return this.progress.get(user.id, Number(bookId));
|
||||
}
|
||||
|
||||
@Put(":bookId")
|
||||
update(
|
||||
@CurrentUserParam() user: CurrentUser,
|
||||
@Param("bookId") bookId: string,
|
||||
@Body(new ZodValidationPipe(UpdateProgressSchema)) body: UpdateProgressDto
|
||||
) {
|
||||
return this.progress.upsert(user.id, Number(bookId), body);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user