authentication
This commit is contained in:
18
api/src/modules/role/role.controller.spec.ts
Normal file
18
api/src/modules/role/role.controller.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { RoleController } from './role.controller';
|
||||
|
||||
describe('RoleController', () => {
|
||||
let controller: RoleController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [RoleController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<RoleController>(RoleController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
15
api/src/modules/role/role.controller.ts
Normal file
15
api/src/modules/role/role.controller.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { RoleService } from './role.service';
|
||||
import { AuthGuard } from 'src/core/guards/auth.guard';
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Controller('role')
|
||||
export class RoleController {
|
||||
|
||||
constructor(private readonly rolesService: RoleService) {}
|
||||
|
||||
@Get()
|
||||
getRoles() {
|
||||
return this.rolesService.getRoles();
|
||||
}
|
||||
}
|
||||
12
api/src/modules/role/role.module.ts
Normal file
12
api/src/modules/role/role.module.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { RoleController } from './role.controller';
|
||||
import { RoleService } from './role.service';
|
||||
import { DatabaseModule } from 'src/shared/database/database.module';
|
||||
import { AuthModule } from '../auth/auth.module';
|
||||
|
||||
@Module({
|
||||
controllers: [RoleController],
|
||||
providers: [RoleService],
|
||||
imports: [ DatabaseModule, AuthModule ]
|
||||
})
|
||||
export class RoleModule {}
|
||||
18
api/src/modules/role/role.service.spec.ts
Normal file
18
api/src/modules/role/role.service.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { RoleService } from './role.service';
|
||||
|
||||
describe('RoleService', () => {
|
||||
let service: RoleService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [RoleService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<RoleService>(RoleService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
11
api/src/modules/role/role.service.ts
Normal file
11
api/src/modules/role/role.service.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { RoleRepository } from 'src/model/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class RoleService {
|
||||
constructor(private readonly rolesRepo: RoleRepository) {}
|
||||
|
||||
getRoles() {
|
||||
return this.rolesRepo.find();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user