Spaces:
Sleeping
Sleeping
Create authentication resource
Browse files- backend/src/modules/authentication/authentication.controller.spec.ts +20 -0
- backend/src/modules/authentication/authentication.controller.ts +34 -0
- backend/src/modules/authentication/authentication.module.ts +9 -0
- backend/src/modules/authentication/authentication.service.spec.ts +18 -0
- backend/src/modules/authentication/authentication.service.ts +26 -0
- backend/src/modules/authentication/dto/create-authentication.dto.ts +1 -0
- backend/src/modules/authentication/dto/update-authentication.dto.ts +4 -0
backend/src/modules/authentication/authentication.controller.spec.ts
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Test, TestingModule } from '@nestjs/testing';
|
2 |
+
import { AuthenticationController } from './authentication.controller';
|
3 |
+
import { AuthenticationService } from './authentication.service';
|
4 |
+
|
5 |
+
describe('AuthenticationController', () => {
|
6 |
+
let controller: AuthenticationController;
|
7 |
+
|
8 |
+
beforeEach(async () => {
|
9 |
+
const module: TestingModule = await Test.createTestingModule({
|
10 |
+
controllers: [AuthenticationController],
|
11 |
+
providers: [AuthenticationService],
|
12 |
+
}).compile();
|
13 |
+
|
14 |
+
controller = module.get<AuthenticationController>(AuthenticationController);
|
15 |
+
});
|
16 |
+
|
17 |
+
it('should be defined', () => {
|
18 |
+
expect(controller).toBeDefined();
|
19 |
+
});
|
20 |
+
});
|
backend/src/modules/authentication/authentication.controller.ts
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
2 |
+
import { AuthenticationService } from './authentication.service';
|
3 |
+
import { CreateAuthenticationDto } from './dto/create-authentication.dto';
|
4 |
+
import { UpdateAuthenticationDto } from './dto/update-authentication.dto';
|
5 |
+
|
6 |
+
@Controller('authentication')
|
7 |
+
export class AuthenticationController {
|
8 |
+
constructor(private readonly authenticationService: AuthenticationService) {}
|
9 |
+
|
10 |
+
@Post()
|
11 |
+
create(@Body() createAuthenticationDto: CreateAuthenticationDto) {
|
12 |
+
return this.authenticationService.create(createAuthenticationDto);
|
13 |
+
}
|
14 |
+
|
15 |
+
@Get()
|
16 |
+
findAll() {
|
17 |
+
return this.authenticationService.findAll();
|
18 |
+
}
|
19 |
+
|
20 |
+
@Get(':id')
|
21 |
+
findOne(@Param('id') id: string) {
|
22 |
+
return this.authenticationService.findOne(+id);
|
23 |
+
}
|
24 |
+
|
25 |
+
@Patch(':id')
|
26 |
+
update(@Param('id') id: string, @Body() updateAuthenticationDto: UpdateAuthenticationDto) {
|
27 |
+
return this.authenticationService.update(+id, updateAuthenticationDto);
|
28 |
+
}
|
29 |
+
|
30 |
+
@Delete(':id')
|
31 |
+
remove(@Param('id') id: string) {
|
32 |
+
return this.authenticationService.remove(+id);
|
33 |
+
}
|
34 |
+
}
|
backend/src/modules/authentication/authentication.module.ts
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Module } from '@nestjs/common';
|
2 |
+
import { AuthenticationService } from './authentication.service';
|
3 |
+
import { AuthenticationController } from './authentication.controller';
|
4 |
+
|
5 |
+
@Module({
|
6 |
+
controllers: [AuthenticationController],
|
7 |
+
providers: [AuthenticationService],
|
8 |
+
})
|
9 |
+
export class AuthenticationModule {}
|
backend/src/modules/authentication/authentication.service.spec.ts
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Test, TestingModule } from '@nestjs/testing';
|
2 |
+
import { AuthenticationService } from './authentication.service';
|
3 |
+
|
4 |
+
describe('AuthenticationService', () => {
|
5 |
+
let service: AuthenticationService;
|
6 |
+
|
7 |
+
beforeEach(async () => {
|
8 |
+
const module: TestingModule = await Test.createTestingModule({
|
9 |
+
providers: [AuthenticationService],
|
10 |
+
}).compile();
|
11 |
+
|
12 |
+
service = module.get<AuthenticationService>(AuthenticationService);
|
13 |
+
});
|
14 |
+
|
15 |
+
it('should be defined', () => {
|
16 |
+
expect(service).toBeDefined();
|
17 |
+
});
|
18 |
+
});
|
backend/src/modules/authentication/authentication.service.ts
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Injectable } from '@nestjs/common';
|
2 |
+
import { CreateAuthenticationDto } from './dto/create-authentication.dto';
|
3 |
+
import { UpdateAuthenticationDto } from './dto/update-authentication.dto';
|
4 |
+
|
5 |
+
@Injectable()
|
6 |
+
export class AuthenticationService {
|
7 |
+
create(createAuthenticationDto: CreateAuthenticationDto) {
|
8 |
+
return 'This action adds a new authentication';
|
9 |
+
}
|
10 |
+
|
11 |
+
findAll() {
|
12 |
+
return `This action returns all authentication`;
|
13 |
+
}
|
14 |
+
|
15 |
+
findOne(id: number) {
|
16 |
+
return `This action returns a #${id} authentication`;
|
17 |
+
}
|
18 |
+
|
19 |
+
update(id: number, updateAuthenticationDto: UpdateAuthenticationDto) {
|
20 |
+
return `This action updates a #${id} authentication`;
|
21 |
+
}
|
22 |
+
|
23 |
+
remove(id: number) {
|
24 |
+
return `This action removes a #${id} authentication`;
|
25 |
+
}
|
26 |
+
}
|
backend/src/modules/authentication/dto/create-authentication.dto.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export class CreateAuthenticationDto {}
|
backend/src/modules/authentication/dto/update-authentication.dto.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { PartialType } from '@nestjs/mapped-types';
|
2 |
+
import { CreateAuthenticationDto } from './create-authentication.dto';
|
3 |
+
|
4 |
+
export class UpdateAuthenticationDto extends PartialType(CreateAuthenticationDto) {}
|