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:
@@ -1,9 +1,13 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UseGuards,
|
||||
@@ -11,9 +15,13 @@ import {
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import {
|
||||
archiveFilesSchema,
|
||||
filePathSchema,
|
||||
listFilesQuerySchema,
|
||||
readFileContentQuerySchema,
|
||||
unarchiveFileSchema,
|
||||
updateFileContentSchema,
|
||||
uploadFileSchema,
|
||||
} from '@hexahost/contracts';
|
||||
|
||||
import { CurrentUser } from '../../auth/decorators/current-user.decorator';
|
||||
@@ -30,7 +38,6 @@ export class FilesController {
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List files in the server data directory' })
|
||||
@ApiResponse({ status: 200, description: 'Directory listing' })
|
||||
list(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@@ -41,7 +48,6 @@ export class FilesController {
|
||||
|
||||
@Get('content')
|
||||
@ApiOperation({ summary: 'Read a text file from the server' })
|
||||
@ApiResponse({ status: 200, description: 'File content' })
|
||||
read(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@@ -53,7 +59,6 @@ export class FilesController {
|
||||
|
||||
@Put('content')
|
||||
@ApiOperation({ summary: 'Write a text file on the server' })
|
||||
@ApiResponse({ status: 200, description: 'Updated file content' })
|
||||
write(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@@ -65,4 +70,59 @@ export class FilesController {
|
||||
body as Parameters<FilesService['writeFile']>[2],
|
||||
);
|
||||
}
|
||||
|
||||
@Post('upload')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@ApiOperation({ summary: 'Upload a file (base64) to the server' })
|
||||
upload(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Body(new ZodValidationPipe(uploadFileSchema)) body: unknown,
|
||||
) {
|
||||
return this.filesService.uploadFile(
|
||||
user.id,
|
||||
serverId,
|
||||
body as Parameters<FilesService['uploadFile']>[2],
|
||||
);
|
||||
}
|
||||
|
||||
@Delete()
|
||||
@ApiOperation({ summary: 'Delete a file or directory' })
|
||||
delete(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Query(new ZodValidationPipe(filePathSchema)) query: { path: string },
|
||||
) {
|
||||
return this.filesService.deleteFile(user.id, serverId, query.path);
|
||||
}
|
||||
|
||||
@Post('archive')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@ApiOperation({ summary: 'Create a tar.gz archive from selected paths' })
|
||||
archive(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Body(new ZodValidationPipe(archiveFilesSchema)) body: unknown,
|
||||
) {
|
||||
return this.filesService.archiveFiles(
|
||||
user.id,
|
||||
serverId,
|
||||
body as Parameters<FilesService['archiveFiles']>[2],
|
||||
);
|
||||
}
|
||||
|
||||
@Post('unarchive')
|
||||
@HttpCode(HttpStatus.ACCEPTED)
|
||||
@ApiOperation({ summary: 'Extract a tar.gz archive on the server' })
|
||||
unarchive(
|
||||
@CurrentUser() user: { id: string },
|
||||
@Param('serverId', ParseUUIDPipe) serverId: string,
|
||||
@Body(new ZodValidationPipe(unarchiveFileSchema)) body: unknown,
|
||||
) {
|
||||
return this.filesService.unarchiveFile(
|
||||
user.id,
|
||||
serverId,
|
||||
body as Parameters<FilesService['unarchiveFile']>[2],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user