katoikia-app/service-a/src/books/books.controller.ts

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-06-29 02:30:10 +00:00
import { Req } from '@nestjs/common';
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
2022-07-25 04:38:48 +00:00
import { Request } from 'express';
2022-06-29 02:30:10 +00:00
import { BooksService } from './books.service';
import { CreateBookDto } from './dto/create-book.dto';
import { UpdateBookDto } from './dto/update-book.dto';
import { BookDocument } from './schemas/book.schema';
@Controller('books')
@ApiTags('book')
export class BooksController {
constructor(private readonly booksService: BooksService) {}
@Post()
create(@Body() book: BookDocument) {
return this.booksService.create(book);
}
@Get()
2022-07-25 04:38:48 +00:00
findAll(@Req() request: Request) {
return this.booksService.findAll(request);
2022-06-29 02:30:10 +00:00
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.booksService.findOne(id);
}
@Patch(':id')
2022-06-29 02:51:06 +00:00
update(@Param('id') id: string, @Body() book: BookDocument) {
return this.booksService.update(id, book);
2022-06-29 02:30:10 +00:00
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.booksService.remove(id);
}
2022-07-25 04:38:48 +00:00
}