-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathadmin-open-api.controller.ts
More file actions
53 lines (45 loc) · 1.8 KB
/
Copy pathadmin-open-api.controller.ts
File metadata and controls
53 lines (45 loc) · 1.8 KB
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
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, Res } from '@nestjs/common';
import {
adminSendNotificationRoSchema,
type IAdminSendNotificationRo,
type IAdminSendNotificationVo,
} from '@teable/openapi';
import { Response } from 'express';
import { ZodValidationPipe } from '../../../zod.validation.pipe';
import { Permissions } from '../../auth/decorators/permissions.decorator';
import { AdminOpenApiService } from './admin-open-api.service';
@Controller('api/admin')
@Permissions('instance|update')
export class AdminOpenApiController {
constructor(private readonly adminService: AdminOpenApiService) {}
@Patch('/plugin/:pluginId/publish')
async publishPlugin(@Param('pluginId') pluginId: string): Promise<void> {
await this.adminService.publishPlugin(pluginId);
}
@Patch('/plugin/:pluginId/unpublish')
async unpublishPlugin(@Param('pluginId') pluginId: string): Promise<void> {
await this.adminService.unpublishPlugin(pluginId);
}
@Post('/attachment/repair-table-thumbnail')
async repairTableAttachmentThumbnail(): Promise<void> {
await this.adminService.repairTableAttachmentThumbnail();
}
@Get('/debug/heap-snapshot')
async getHeapSnapshot(@Res() res: Response): Promise<void> {
await this.adminService.getHeapSnapshot(res);
}
@Get('performance-cache-stats')
async getPerformanceCache() {
return await this.adminService.getPerformanceCache();
}
@Delete('performance-cache')
async deletePerformanceCache(@Query('key') key?: string) {
return await this.adminService.deletePerformanceCache(key);
}
@Post('notification')
async sendNotification(
@Body(new ZodValidationPipe(adminSendNotificationRoSchema)) ro: IAdminSendNotificationRo
): Promise<IAdminSendNotificationVo> {
return this.adminService.sendAdminNotification(ro);
}
}