Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import { Controller, Get, Post, Param, Body, Query } from '@nestjs/common'; import { JobSchedulerService } from './scheduler.service'; import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; @Controller('api/v1/admin') @ApiTags('Scheduler') export class SchedulerController { constructor(private readonly schedulerService: JobSchedulerService) {} @Get('jobs') @ApiOperation({ summary: 'Get definitions operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) async getDefinitions() { return this.schedulerService.getDefinitions(); } @Post('jobs') @ApiOperation({ summary: 'Create job definition operation' }) @ApiResponse({ status: 201, description: 'Operation successful' }) async createJobDefinition( @Body() body: { name: string; cron: string; payload?: any; timeoutMs?: number; retries?: number; }, ) { return this.schedulerService.createJobDefinition(body); } @Post('jobs/:name/run') @ApiOperation({ summary: 'Trigger job operation' }) @ApiResponse({ status: 201, description: 'Operation successful' }) async triggerJob(@Param('name') name: string) { return this.schedulerService.triggerJob(name); } @Get('queues/health') @ApiOperation({ summary: 'Get health operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) async getHealth() { return this.schedulerService.getQueueHealth(); } @Get('executions') @ApiOperation({ summary: 'Get executions operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) async getExecutions( @Query('page') page: string, @Query('limit') limit: string, ) { return this.schedulerService.getExecutions( page ? parseInt(page) : 1, limit ? parseInt(limit) : 20, ); } } |