authentication

This commit is contained in:
Bastian Wagner
2024-09-13 21:14:09 +02:00
parent c00aad559d
commit b4a5f04505
65 changed files with 1140 additions and 77 deletions

View 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();
});
});

View 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();
}
}

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

View 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();
});
});

View 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();
}
}