Spaces:
Sleeping
Sleeping
Download src/modules/plugins/plugins.controller.ts from jinksQspider/openWa: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/plugins/plugins.controller.ts
- Command line
-
hf download hf://spaces/jinksQspider/openWa/src/modules/plugins/plugins.controller.ts
-
curl -L -o plugins.controller.ts https://huggingface.co/spaces/jinksQspider/openWa/resolve/main/src/modules/plugins/plugins.controller.ts
2.42 kB
| import { Controller, Get, Post, Put, Param, Body, HttpCode, HttpStatus } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; | |
| import { PluginsService } from './plugins.service'; | |
| import { PluginDto, PluginConfigDto } from './dto/plugin.dto'; | |
| import { RequireRole } from '../auth/decorators/auth.decorators'; | |
| import { ApiKeyRole } from '../auth/entities/api-key.entity'; | |
| ('plugins') | |
| ('plugins') | |
| export class PluginsController { | |
| constructor(private readonly pluginsService: PluginsService) {} | |
| () | |
| ({ summary: 'List all plugins' }) | |
| ({ status: 200, description: 'List of all plugins' }) | |
| findAll(): PluginDto[] { | |
| return this.pluginsService.findAll(); | |
| } | |
| (':id') | |
| ({ summary: 'Get plugin by ID' }) | |
| ({ status: 200, description: 'Plugin details' }) | |
| ({ status: 404, description: 'Plugin not found' }) | |
| findOne(('id') id: string): PluginDto { | |
| return this.pluginsService.findOne(id); | |
| } | |
| (':id/enable') | |
| (ApiKeyRole.ADMIN) | |
| (HttpStatus.OK) | |
| ({ summary: 'Enable a plugin' }) | |
| ({ status: 200, description: 'Plugin enabled successfully' }) | |
| async enable(('id') id: string): Promise<{ success: boolean; message: string }> { | |
| return await this.pluginsService.enable(id); | |
| } | |
| (':id/disable') | |
| (ApiKeyRole.ADMIN) | |
| (HttpStatus.OK) | |
| ({ summary: 'Disable a plugin' }) | |
| ({ status: 200, description: 'Plugin disabled successfully' }) | |
| async disable(('id') id: string): Promise<{ success: boolean; message: string }> { | |
| return await this.pluginsService.disable(id); | |
| } | |
| (':id/config') | |
| (ApiKeyRole.ADMIN) | |
| ({ summary: 'Update plugin configuration' }) | |
| ({ status: 200, description: 'Plugin configuration updated' }) | |
| updateConfig(('id') id: string, () configDto: PluginConfigDto): { success: boolean; message: string } { | |
| return this.pluginsService.updateConfig(id, configDto.config); | |
| } | |
| (':id/health') | |
| ({ summary: 'Check plugin health' }) | |
| ({ status: 200, description: 'Plugin health status' }) | |
| async healthCheck(('id') id: string): Promise<{ healthy: boolean; message?: string }> { | |
| return await this.pluginsService.healthCheck(id); | |
| } | |
| } | |