Enhance API with OIDC support, including login and callback endpoints. Update environment variables for OIDC configuration in .env.example. Add new features to the catalog service for listing software families, Minecraft versions, and deployment regions. Implement server management actions such as kill, delete, and update in the servers module. Integrate feature flags for maintenance mode in server operations. Update pnpm-lock.yaml with new dependencies and versions.
This commit is contained in:
77
apps/api/src/servers/schedules/schedules.controller.ts
Normal file
77
apps/api/src/servers/schedules/schedules.controller.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Patch,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { createScheduleSchema, updateScheduleSchema } from '@hexahost/contracts';
|
||||
|
||||
import { CurrentUser } from '../../auth/decorators/current-user.decorator';
|
||||
import { SessionGuard } from '../../auth/guards/session.guard';
|
||||
import { ZodValidationPipe } from '../../common/pipes/zod-validation.pipe';
|
||||
|
||||
import { SchedulesService } from './schedules.service';
|
||||
|
||||
@ApiTags('servers')
|
||||
@Controller('servers/:serverId/schedules')
|
||||
@UseGuards(SessionGuard)
|
||||
export class SchedulesController {
|
||||
constructor(private readonly schedulesService: SchedulesService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List server schedules' })
|
||||
list(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
) {
|
||||
return this.schedulesService.list(user.id, serverId);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
create(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Body(new ZodValidationPipe(createScheduleSchema)) body: unknown,
|
||||
) {
|
||||
return this.schedulesService.create(
|
||||
user.id,
|
||||
serverId,
|
||||
body as Parameters<SchedulesService['create']>[2],
|
||||
);
|
||||
}
|
||||
|
||||
@Patch(':scheduleId')
|
||||
update(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Param('scheduleId', ParseUUIDPipe) scheduleId: string,
|
||||
@Body(new ZodValidationPipe(updateScheduleSchema)) body: unknown,
|
||||
) {
|
||||
return this.schedulesService.update(
|
||||
user.id,
|
||||
serverId,
|
||||
scheduleId,
|
||||
body as Parameters<SchedulesService['update']>[3],
|
||||
);
|
||||
}
|
||||
|
||||
@Delete(':scheduleId')
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
async remove(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Param('scheduleId', ParseUUIDPipe) scheduleId: string,
|
||||
) {
|
||||
await this.schedulesService.remove(user.id, serverId, scheduleId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user