feat: add admin module
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TestsController } from './controllers/tests/tests.controller';
|
||||
import { TestsModule } from '../tests/tests.module';
|
||||
|
||||
@Module({
|
||||
imports: [TestsModule],
|
||||
controllers: [TestsController],
|
||||
})
|
||||
export class AdminModule {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Role } from '@/common/enums/roles.enum';
|
||||
import { Roles } from '@/modules/auth/decorators/roles.decorator';
|
||||
import { CreateTestDTO } from '@/modules/tests/dtos/create-test.dto';
|
||||
import { TestsService } from '@/modules/tests/providers/tests.service';
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
|
||||
@Controller('admin/tests')
|
||||
export class TestsController {
|
||||
constructor(
|
||||
/**
|
||||
* Inject Tests Service
|
||||
*/
|
||||
private readonly testsService: TestsService,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
@Roles(Role.SUPERUSER, Role.ADMIN)
|
||||
public async createTest(@Body() createTestDto: CreateTestDTO) {
|
||||
return await this.testsService.createOne(createTestDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
POST http://localhost:3000/admin/tests/
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEwLCJwaG9uZSI6IjA5MzMzMDI2MzYzIiwiaWF0IjoxNzgwMjIzNDExLCJleHAiOjE3ODAyMjcwMTEsImF1ZCI6ImxvY2FsaG9zdCIsImlzcyI6ImxvY2FsaG9zdCJ9.FNTIrk6FKO8P88yKnRCybZ6E5N3KlJaCHqZt5DMVgds
|
||||
|
||||
{
|
||||
"title": "Test Three",
|
||||
"description": "Description Three",
|
||||
"accessType": "free",
|
||||
"price": "1234000",
|
||||
"isActive": true
|
||||
}
|
||||
Reference in New Issue
Block a user