Skip to content

Commit

Permalink
Create role
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet-agrahari committed Feb 25, 2024
1 parent 1621248 commit d590e01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/role/role.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Controller, Get } from '@nestjs/common';
import { Body, Controller, Get, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Role } from './role.entity';
import { RoleService } from './role.service';
import { CreateRoleDto } from './dto/create-role.dto';

@ApiTags('Role')
@Controller('roles')
Expand All @@ -12,4 +13,9 @@ export class RoleController {
async getAllRoles(): Promise<Role[]> {
return this.roleService.getAllRoles();
}

@Post()
async createRole(@Body() createRoleDto: CreateRoleDto) {
return this.roleService.createRole(createRoleDto);
}
}
4 changes: 4 additions & 0 deletions src/role/role.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export class RoleService {
async getAllRoles(): Promise<Role[]> {
return this.roleRepository.find();
}

async createRole(createRoleDto) {
return this.roleRepository.create(createRoleDto);
}
}

0 comments on commit d590e01

Please sign in to comment.