import { Controller , Get , Param , Post , Body , Query , Delete } from '@nestjs/common' ; import { BooksService } from './books.service' ; import { CreateBookDTO } from './dto/create-book.dto' ; @ Controller ( 'books' ) export class BooksController { constructor ( private booksService ) { } @ Get ( ) async getBooks ( ) { const books = await this . booksService . getBooks ( ) ; return books ; } @ Get ( ':bookID' ) async getBook ( @ Param ( 'bookID' ) bookID ) { const book = await this . booksService . getBook ( bookID ) ; return book ; } @ Post ( ) async addBook ( @ Body ( ) createBookDTO ) { const book = await this . booksService . addBook ( createBookDTO ) ; return book ; } @ Delete ( ) async deleteBook ( @ Query ( ) query ) { const books = await this . booksService . deleteBook ( query . bookID ) ; return books ; } }