empty auth
This commit is contained in:
parent
963797c7ae
commit
16aed5a76d
@ -1,18 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { AuthController } from './auth.controller';
|
|
||||||
|
|
||||||
describe('AuthController', () => {
|
|
||||||
let controller: AuthController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [AuthController],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
controller = module.get<AuthController>(AuthController);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(controller).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
import { LoginDto } from './dto/login.dto';
|
|
||||||
import { RegisterDto } from './dto/register.dto';
|
|
||||||
|
|
||||||
@Controller('auth')
|
|
||||||
export class AuthController {
|
|
||||||
constructor(private readonly authService: AuthService) {}
|
|
||||||
|
|
||||||
|
|
||||||
//Route pour se connecter
|
|
||||||
@Post('login')
|
|
||||||
login(@Body() loginDto: LoginDto) {
|
|
||||||
return this.authService.login(loginDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Route pour s'inscrire
|
|
||||||
@Post('register')
|
|
||||||
register(@Body() registerDto: RegisterDto) {
|
|
||||||
return this.authService.register(registerDto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { AuthController } from './auth.controller';
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
controllers: [AuthController],
|
|
||||||
providers: [AuthService]
|
|
||||||
})
|
|
||||||
export class AuthModule {}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
describe('AuthService', () => {
|
|
||||||
let service: AuthService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [AuthService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<AuthService>(AuthService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { LoginDto } from './dto/login.dto';
|
|
||||||
import { RegisterDto } from './dto/register.dto';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthService {
|
|
||||||
|
|
||||||
register(registerDto: RegisterDto) {
|
|
||||||
return {
|
|
||||||
message: `User registered successfully ${registerDto}`,
|
|
||||||
user: registerDto,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
login(loginDto: LoginDto) {
|
|
||||||
return {
|
|
||||||
message: `Login successful ${loginDto.email}`,
|
|
||||||
user: loginDto,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import { IsEmail, MinLength } from 'class-validator';
|
|
||||||
|
|
||||||
export class LoginDto {
|
|
||||||
@IsEmail()
|
|
||||||
email: string;
|
|
||||||
|
|
||||||
@MinLength(8)
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
import { IsEmail, IsNotEmpty, MaxLength, MinLength } from "class-validator";
|
|
||||||
|
|
||||||
export class RegisterDto {
|
|
||||||
|
|
||||||
@IsEmail()
|
|
||||||
email: string;
|
|
||||||
|
|
||||||
@IsNotEmpty()
|
|
||||||
username: string;
|
|
||||||
|
|
||||||
@MinLength(8)
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user