feat: add admin module

This commit is contained in:
2026-06-01 14:45:01 +03:30
parent 7dda2564a8
commit 967b96184a
30 changed files with 335 additions and 30 deletions
+9
View File
@@ -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
}