Merge branch 'web-ui' into main

This commit is contained in:
Mariela 2022-06-28 20:51:34 -06:00
commit 612056b7e3
19 changed files with 4 additions and 234 deletions

View File

@ -2,16 +2,12 @@ import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { UsersModule } from './users/users.module';
import { BooksModule } from './books/books.module'; import { BooksModule } from './books/books.module';
import { CategoriesModule } from './categories/categories.module';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`), MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`),
BooksModule, BooksModule,
UsersModule,
CategoriesModule,
], ],
controllers: [AppController], controllers: [AppController],
providers: [AppService], providers: [AppService],

View File

@ -36,8 +36,8 @@ export class BooksController {
} }
@Patch(':id') @Patch(':id')
update(@Param('id') id: string, @Body() updateBookDto: UpdateBookDto) { update(@Param('id') id: string, @Body() book: BookDocument) {
return this.booksService.update(id, updateBookDto); return this.booksService.update(id, book);
} }
@Delete(':id') @Delete(':id')

View File

@ -27,8 +27,8 @@ export class BooksService {
return this.bookModel.findOne({ _id: id }).exec(); return this.bookModel.findOne({ _id: id }).exec();
} }
async update(id: string, updateBookDto: UpdateBookDto) { async update(id: string, book: BookDocument) {
return this.bookModel.findOneAndUpdate({ _id: id }, updateBookDto, { return this.bookModel.findOneAndUpdate({ _id: id }, book, {
new: true, new: true,
}); });
} }

View File

@ -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>(CategoriesController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@ -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);
}
}

View File

@ -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 {}

View File

@ -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>(CategoriesService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@ -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`;
}
}

View File

@ -1 +0,0 @@
export class CreateCategoryDto {}

View File

@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateCategoryDto } from './create-category.dto';
export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}

View File

@ -1 +0,0 @@
export class Category {}

View File

@ -1 +0,0 @@
export class CreateUserDto {}

View File

@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateUserDto } from './create-user.dto';
export class UpdateUserDto extends PartialType(CreateUserDto) {}

View File

@ -1 +0,0 @@
export class User {}

View File

@ -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>(UsersController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@ -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);
}
}

View File

@ -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 {}

View File

@ -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>(UsersService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@ -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`;
}
}