diff --git a/backend/src/admin/admin.module.ts b/backend/src/admin/admin.module.ts index fdad70955caf5f10946193c3aaf0747451b3cf6e..98d4be261cc4c1ccc2d8642c1e4f5916ed0ad463 100644 --- a/backend/src/admin/admin.module.ts +++ b/backend/src/admin/admin.module.ts @@ -1,8 +1,11 @@ import { Module } from '@nestjs/common'; import { AdminService } from './admin.service'; import { AdminController } from './admin.controller'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Admin } from './entities/admin.entity'; @Module({ + imports: [TypeOrmModule.forFeature([Admin])], controllers: [AdminController], providers: [AdminService], exports: [AdminService], diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index 4ef4d3a5d00155b97dce2ae39ff4b80bd33ae7e5..61dcd22aa94bb66efc76111eec52041026d5cadc 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -6,7 +6,6 @@ import { UpdateAdminDto } from './dto/update-admin.dto'; export class AdminService { private readonly admin = [ { - id: 1, name: 'Admin prueba', email: 'admin@gmail.com', password: 'admin123', @@ -25,12 +24,4 @@ export class AdminService { return this.admin.find((admin) => admin.email === email); } - - update(id: number, updateAdminDto: UpdateAdminDto) { - return `This action updates a #${id} admin`; - } - - remove(id: number) { - return `This action removes a #${id} admin`; - } } diff --git a/backend/src/admin/dto/create-admin.dto.ts b/backend/src/admin/dto/create-admin.dto.ts index 81a9eaaba4dd9bc7fd1a2c3e74d771bef7dd8510..a59551de93d414d04ef58c20d58ef7b23d0f20c2 100644 --- a/backend/src/admin/dto/create-admin.dto.ts +++ b/backend/src/admin/dto/create-admin.dto.ts @@ -1,5 +1,4 @@ export class CreateAdminDto { - id : number; name: string; email: string; password: string; diff --git a/backend/src/app.controller.ts b/backend/src/app.controller.ts index 1739a152f3a9ef4b6cad39a61006b0a8262a75ca..939ee598d79ce558bef4ccca91ce4bc5166aaab9 100644 --- a/backend/src/app.controller.ts +++ b/backend/src/app.controller.ts @@ -1,12 +1,19 @@ import { Controller, Get } from '@nestjs/common'; import { AppService } from './app.service'; + @Controller() export class AppController { constructor(private readonly appService: AppService) {} - @Get()//decorador + @Get() // decorator getHello(): string { return this.appService.getHello(); } + + @Get('admin') // new endpoint for admin panel + getAdminPanel(): string { + + return 'Admin Panel'; + } } diff --git a/backend/src/auth/auth-admin/auth-admin.controller.spec.ts b/backend/src/auth/auth-admin/auth-admin.controller.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac40a3fea6b0ec5a6c0ce01e7c13b3481ce3748f --- /dev/null +++ b/backend/src/auth/auth-admin/auth-admin.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AuthAdminController } from './auth-admin.controller'; +import { AuthAdminService } from './auth-admin.service'; + +describe('AuthAdminController', () => { + let controller: AuthAdminController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [AuthAdminController], + providers: [AuthAdminService], + }).compile(); + + controller = module.get(AuthAdminController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/backend/src/auth/auth-admin/auth-admin.controller.ts b/backend/src/auth/auth-admin/auth-admin.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..56da9cd4e091fe929d8d30cb28a0717e2dc0ccde --- /dev/null +++ b/backend/src/auth/auth-admin/auth-admin.controller.ts @@ -0,0 +1,34 @@ +import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { AuthAdminService } from './auth-admin.service'; +import { CreateAuthAdminDto } from './dto/login-admin.dto'; +import { UpdateAuthAdminDto } from './dto/update-auth-admin.dto'; + +@Controller('auth-admin') +export class AuthAdminController { + constructor(private readonly authAdminService: AuthAdminService) {} + + @Post() + create(@Body() createAuthAdminDto: CreateAuthAdminDto) { + return this.authAdminService.create(createAuthAdminDto); + } + + @Get() + findAll() { + return this.authAdminService.findAll(); + } + + @Get(':id') + findOne(@Param('id') id: string) { + return this.authAdminService.findOne(+id); + } + + @Patch(':id') + update(@Param('id') id: string, @Body() updateAuthAdminDto: UpdateAuthAdminDto) { + return this.authAdminService.update(+id, updateAuthAdminDto); + } + + @Delete(':id') + remove(@Param('id') id: string) { + return this.authAdminService.remove(+id); + } +} diff --git a/backend/src/auth/auth-admin/auth-admin.module.ts b/backend/src/auth/auth-admin/auth-admin.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..faa19508c24475f5498808ff4202b5ab131f4ce3 --- /dev/null +++ b/backend/src/auth/auth-admin/auth-admin.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { AuthAdminService } from './auth-admin.service'; +import { AuthAdminController } from './auth-admin.controller'; + +@Module({ + controllers: [AuthAdminController], + providers: [AuthAdminService], +}) +export class AuthAdminModule {} diff --git a/backend/src/auth/auth-admin/auth-admin.service.spec.ts b/backend/src/auth/auth-admin/auth-admin.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..644828c76cbe36e0d65192ef4103c1fe84ac99b6 --- /dev/null +++ b/backend/src/auth/auth-admin/auth-admin.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AuthAdminService } from './auth-admin.service'; + +describe('AuthAdminService', () => { + let service: AuthAdminService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [AuthAdminService], + }).compile(); + + service = module.get(AuthAdminService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/backend/src/auth/auth-admin/auth-admin.service.ts b/backend/src/auth/auth-admin/auth-admin.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..54bee0b14c84e26e1de7ff3b8dcaec45acc6ca5f --- /dev/null +++ b/backend/src/auth/auth-admin/auth-admin.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@nestjs/common'; +import { CreateAuthAdminDto } from './dto/login-admin.dto'; +import { UpdateAuthAdminDto } from './dto/update-auth-admin.dto'; + +@Injectable() +export class AuthAdminService { + create(createAuthAdminDto: CreateAuthAdminDto) { + return 'This action adds a new authAdmin'; + } + + findAll() { + return `This action returns all authAdmin`; + } + + findOne(id: number) { + return `This action returns a #${id} authAdmin`; + } + + update(id: number, updateAuthAdminDto: UpdateAuthAdminDto) { + return `This action updates a #${id} authAdmin`; + } + + remove(id: number) { + return `This action removes a #${id} authAdmin`; + } +} diff --git a/backend/src/auth/auth-admin/dto/login-admin.dto.ts b/backend/src/auth/auth-admin/dto/login-admin.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..143ec6707acb7f15209f4f41d0d2c8ba9be4c5c1 --- /dev/null +++ b/backend/src/auth/auth-admin/dto/login-admin.dto.ts @@ -0,0 +1,19 @@ +import { Transform } from "class-transformer"; +import { IsEmail, IsString, MinLength } from "class-validator"; +export class loginAdmin { + @IsEmail() + email: string; + + @IsString() + @MinLength(6) + @Transform(({ value }) => value.trim()) + password: string; + + static adminCount: number = 0; + + constructor(email: string, password: string) { + this.email = email; + this.password = password; + loginAdmin.adminCount++; + } +} diff --git a/backend/src/auth/auth-admin/entities/auth-admin.entity.ts b/backend/src/auth/auth-admin/entities/auth-admin.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..e29fdcb15f541619acd96d3807a9ddbb30acdbd7 --- /dev/null +++ b/backend/src/auth/auth-admin/entities/auth-admin.entity.ts @@ -0,0 +1 @@ +export class AuthAdmin {} diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 5a3f9fee307f9d109d587ae524265f1cdcd5ca6d..2deda19cd3ffc0f958a20dd000da7cad3c732af1 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -1,29 +1,22 @@ import { Injectable } from '@nestjs/common'; import { CreateUserDto } from './dto/create-user.dto'; import { UpdateUserDto } from './dto/update-user.dto'; +import { InjectRepository } from '@nestjs/typeorm'; +import { User } from './entities/user.entity'; +import { Repository } from 'typeorm'; @Injectable() export class UserService { + constructor( + @InjectRepository(User) + private readonly userRepository: Repository, + ) {} create(createUserDto: CreateUserDto) { - + return this.userRepository.save(createUserDto); } - findAll() { - return `This action returns all user`; + async findOneByEmail(email: string) { + return await this.userRepository.findOneBy({ email }); } - findOne(email: string) { - return `This action returns a #${email} user`; - } - - update(id: number, updateUserDto: UpdateUserDto) { - return `This action updates a #${id} user`; - } - - remove(id: number) { - return `This action removes a #${id} user`; - } - save(newUser: any) { - throw new Error('Method not implemented.'); - } } diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index 894899e3451e6d455d7807b73aec5e4d2b0425fa..723ddd69337c889a25f13a7d38a0cd521aca7ccf 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 url: "https://pub.dev" source: hosted - version: "1.0.6" + version: "1.0.8" dio: dependency: "direct main" description: @@ -92,10 +92,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: "771c8feb40ad0ef639973d7ecf1b43d55ffcedb2207fd43fab030f5639e40446" + sha256: b465e99ce64ba75e61c8c0ce3d87b66d8ac07f0b35d0a7e0263fcfc10f99e836 url: "https://pub.dev" source: hosted - version: "13.2.4" + version: "13.2.5" http_parser: dependency: transitive description: