diff --git a/service-a/src/app.module.ts b/service-a/src/app.module.ts index ba4eccf4..541eebc9 100644 --- a/service-a/src/app.module.ts +++ b/service-a/src/app.module.ts @@ -2,16 +2,12 @@ import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { MongooseModule } from '@nestjs/mongoose'; -import { UsersModule } from './users/users.module'; import { BooksModule } from './books/books.module'; -import { CategoriesModule } from './categories/categories.module'; @Module({ imports: [ MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`), BooksModule, - UsersModule, - CategoriesModule, ], controllers: [AppController], providers: [AppService], diff --git a/service-a/src/books/books.controller.ts b/service-a/src/books/books.controller.ts index babb983a..109fa967 100644 --- a/service-a/src/books/books.controller.ts +++ b/service-a/src/books/books.controller.ts @@ -36,8 +36,8 @@ export class BooksController { } @Patch(':id') - update(@Param('id') id: string, @Body() updateBookDto: UpdateBookDto) { - return this.booksService.update(id, updateBookDto); + update(@Param('id') id: string, @Body() book: BookDocument) { + return this.booksService.update(id, book); } @Delete(':id') diff --git a/service-a/src/books/books.service.ts b/service-a/src/books/books.service.ts index 0f65f1af..d506c6c0 100644 --- a/service-a/src/books/books.service.ts +++ b/service-a/src/books/books.service.ts @@ -27,8 +27,8 @@ export class BooksService { return this.bookModel.findOne({ _id: id }).exec(); } - async update(id: string, updateBookDto: UpdateBookDto) { - return this.bookModel.findOneAndUpdate({ _id: id }, updateBookDto, { + async update(id: string, book: BookDocument) { + return this.bookModel.findOneAndUpdate({ _id: id }, book, { new: true, }); } diff --git a/service-a/src/categories/categories.controller.spec.ts b/service-a/src/categories/categories.controller.spec.ts deleted file mode 100644 index 66257dec..00000000 --- a/service-a/src/categories/categories.controller.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { CategoriesController } from './categories.controller'; -import { CategoriesService } from './categories.service'; - -describe('CategoriesController', () => { - let controller: CategoriesController; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - controllers: [CategoriesController], - providers: [CategoriesService], - }).compile(); - - controller = module.get(CategoriesController); - }); - - it('should be defined', () => { - expect(controller).toBeDefined(); - }); -}); diff --git a/service-a/src/categories/categories.controller.ts b/service-a/src/categories/categories.controller.ts deleted file mode 100644 index 8c865d66..00000000 --- a/service-a/src/categories/categories.controller.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; -import { CategoriesService } from './categories.service'; -import { CreateCategoryDto } from './dto/create-category.dto'; -import { UpdateCategoryDto } from './dto/update-category.dto'; - -@Controller('categories') -export class CategoriesController { - constructor(private readonly categoriesService: CategoriesService) {} - - @Post() - create(@Body() createCategoryDto: CreateCategoryDto) { - return this.categoriesService.create(createCategoryDto); - } - - @Get() - findAll() { - return this.categoriesService.findAll(); - } - - @Get(':id') - findOne(@Param('id') id: string) { - return this.categoriesService.findOne(+id); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { - return this.categoriesService.update(+id, updateCategoryDto); - } - - @Delete(':id') - remove(@Param('id') id: string) { - return this.categoriesService.remove(+id); - } -} diff --git a/service-a/src/categories/categories.module.ts b/service-a/src/categories/categories.module.ts deleted file mode 100644 index 8776b448..00000000 --- a/service-a/src/categories/categories.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common'; -import { CategoriesService } from './categories.service'; -import { CategoriesController } from './categories.controller'; - -@Module({ - controllers: [CategoriesController], - providers: [CategoriesService] -}) -export class CategoriesModule {} diff --git a/service-a/src/categories/categories.service.spec.ts b/service-a/src/categories/categories.service.spec.ts deleted file mode 100644 index 9095d781..00000000 --- a/service-a/src/categories/categories.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { CategoriesService } from './categories.service'; - -describe('CategoriesService', () => { - let service: CategoriesService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [CategoriesService], - }).compile(); - - service = module.get(CategoriesService); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); -}); diff --git a/service-a/src/categories/categories.service.ts b/service-a/src/categories/categories.service.ts deleted file mode 100644 index 04d46417..00000000 --- a/service-a/src/categories/categories.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { CreateCategoryDto } from './dto/create-category.dto'; -import { UpdateCategoryDto } from './dto/update-category.dto'; - -@Injectable() -export class CategoriesService { - create(createCategoryDto: CreateCategoryDto) { - return 'This action adds a new category'; - } - - findAll() { - return `This action returns all categories`; - } - - findOne(id: number) { - return `This action returns a #${id} category`; - } - - update(id: number, updateCategoryDto: UpdateCategoryDto) { - return `This action updates a #${id} category`; - } - - remove(id: number) { - return `This action removes a #${id} category`; - } -} diff --git a/service-a/src/categories/dto/create-category.dto.ts b/service-a/src/categories/dto/create-category.dto.ts deleted file mode 100644 index 4f8ca2fc..00000000 --- a/service-a/src/categories/dto/create-category.dto.ts +++ /dev/null @@ -1 +0,0 @@ -export class CreateCategoryDto {} diff --git a/service-a/src/categories/dto/update-category.dto.ts b/service-a/src/categories/dto/update-category.dto.ts deleted file mode 100644 index d713b9b9..00000000 --- a/service-a/src/categories/dto/update-category.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { PartialType } from '@nestjs/swagger'; -import { CreateCategoryDto } from './create-category.dto'; - -export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {} diff --git a/service-a/src/categories/schemas/category.schema.ts b/service-a/src/categories/schemas/category.schema.ts deleted file mode 100644 index 6f4fd523..00000000 --- a/service-a/src/categories/schemas/category.schema.ts +++ /dev/null @@ -1 +0,0 @@ -export class Category {} diff --git a/service-a/src/users/dto/create-user.dto.ts b/service-a/src/users/dto/create-user.dto.ts deleted file mode 100644 index 0311be13..00000000 --- a/service-a/src/users/dto/create-user.dto.ts +++ /dev/null @@ -1 +0,0 @@ -export class CreateUserDto {} diff --git a/service-a/src/users/dto/update-user.dto.ts b/service-a/src/users/dto/update-user.dto.ts deleted file mode 100644 index 78ab602d..00000000 --- a/service-a/src/users/dto/update-user.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { PartialType } from '@nestjs/swagger'; -import { CreateUserDto } from './create-user.dto'; - -export class UpdateUserDto extends PartialType(CreateUserDto) {} diff --git a/service-a/src/users/schemas/user.schema.ts b/service-a/src/users/schemas/user.schema.ts deleted file mode 100644 index 4f82c145..00000000 --- a/service-a/src/users/schemas/user.schema.ts +++ /dev/null @@ -1 +0,0 @@ -export class User {} diff --git a/service-a/src/users/users.controller.spec.ts b/service-a/src/users/users.controller.spec.ts deleted file mode 100644 index a76d3103..00000000 --- a/service-a/src/users/users.controller.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { UsersController } from './users.controller'; -import { UsersService } from './users.service'; - -describe('UsersController', () => { - let controller: UsersController; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - controllers: [UsersController], - providers: [UsersService], - }).compile(); - - controller = module.get(UsersController); - }); - - it('should be defined', () => { - expect(controller).toBeDefined(); - }); -}); diff --git a/service-a/src/users/users.controller.ts b/service-a/src/users/users.controller.ts deleted file mode 100644 index 3eca7ebd..00000000 --- a/service-a/src/users/users.controller.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; -import { UsersService } from './users.service'; -import { CreateUserDto } from './dto/create-user.dto'; -import { UpdateUserDto } from './dto/update-user.dto'; - -@Controller('users') -export class UsersController { - constructor(private readonly usersService: UsersService) {} - - @Post() - create(@Body() createUserDto: CreateUserDto) { - return this.usersService.create(createUserDto); - } - - @Get() - findAll() { - return this.usersService.findAll(); - } - - @Get(':id') - findOne(@Param('id') id: string) { - return this.usersService.findOne(+id); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { - return this.usersService.update(+id, updateUserDto); - } - - @Delete(':id') - remove(@Param('id') id: string) { - return this.usersService.remove(+id); - } -} diff --git a/service-a/src/users/users.module.ts b/service-a/src/users/users.module.ts deleted file mode 100644 index 51f12f03..00000000 --- a/service-a/src/users/users.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common'; -import { UsersService } from './users.service'; -import { UsersController } from './users.controller'; - -@Module({ - controllers: [UsersController], - providers: [UsersService] -}) -export class UsersModule {} diff --git a/service-a/src/users/users.service.spec.ts b/service-a/src/users/users.service.spec.ts deleted file mode 100644 index 62815ba6..00000000 --- a/service-a/src/users/users.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { UsersService } from './users.service'; - -describe('UsersService', () => { - let service: UsersService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [UsersService], - }).compile(); - - service = module.get(UsersService); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); -}); diff --git a/service-a/src/users/users.service.ts b/service-a/src/users/users.service.ts deleted file mode 100644 index 0a55903d..00000000 --- a/service-a/src/users/users.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { CreateUserDto } from './dto/create-user.dto'; -import { UpdateUserDto } from './dto/update-user.dto'; - -@Injectable() -export class UsersService { - create(createUserDto: CreateUserDto) { - return 'This action adds a new user'; - } - - findAll() { - return `This action returns all users`; - } - - findOne(id: number) { - return `This action returns a #${id} user`; - } - - update(id: number, updateUserDto: UpdateUserDto) { - return `This action updates a #${id} user`; - } - - remove(id: number) { - return `This action removes a #${id} user`; - } -}