@@ -18,7 +18,12 @@ import {
|
||||
CACHE_MANAGER,
|
||||
} from "@nestjs/cache-manager";
|
||||
import * as cacheManager from "cache-manager";
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse as SwaggerResponse } from "@nestjs/swagger";
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiResponse as SwaggerResponse,
|
||||
} from "@nestjs/swagger";
|
||||
import { Roles } from "../../common/decorators";
|
||||
import { PrismaService } from "../../database/prisma.service";
|
||||
import { PaginationDto } from "../../common/dto/pagination.dto";
|
||||
@@ -181,7 +186,10 @@ export class AdminController {
|
||||
@CacheKey("app_settings")
|
||||
@CacheTTL(60 * 1000)
|
||||
@ApiOperation({ summary: "Get all app settings" })
|
||||
@SwaggerResponse({ status: 200, schema: { type: "object", additionalProperties: { type: "string" } } })
|
||||
@SwaggerResponse({
|
||||
status: 200,
|
||||
schema: { type: "object", additionalProperties: { type: "string" } },
|
||||
})
|
||||
async getAllSettings(): Promise<ApiResponse<Record<string, string>>> {
|
||||
const settings = await this.prisma.appSetting.findMany();
|
||||
const settingsMap: Record<string, string> = {};
|
||||
@@ -193,7 +201,13 @@ export class AdminController {
|
||||
|
||||
@Put("settings/:key")
|
||||
@ApiOperation({ summary: "Update an app setting" })
|
||||
@SwaggerResponse({ status: 200, schema: { type: "object", properties: { key: { type: "string" }, value: { type: "string" } } } })
|
||||
@SwaggerResponse({
|
||||
status: 200,
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: { key: { type: "string" }, value: { type: "string" } },
|
||||
},
|
||||
})
|
||||
async updateSetting(
|
||||
@Param("key") key: string,
|
||||
@Body() data: { value: string },
|
||||
@@ -214,7 +228,10 @@ export class AdminController {
|
||||
|
||||
@Get("usage-limits")
|
||||
@ApiOperation({ summary: "Get all usage limits" })
|
||||
@SwaggerResponse({ status: 200, schema: { type: "array", items: { type: "object" } } })
|
||||
@SwaggerResponse({
|
||||
status: 200,
|
||||
schema: { type: "array", items: { type: "object" } },
|
||||
})
|
||||
async getAllUsageLimits(@Query() pagination: PaginationDto) {
|
||||
const { skip, take } = pagination;
|
||||
|
||||
@@ -242,7 +259,10 @@ export class AdminController {
|
||||
|
||||
@Post("usage-limits/reset-all")
|
||||
@ApiOperation({ summary: "Reset all usage limits" })
|
||||
@SwaggerResponse({ status: 200, schema: { type: "object", properties: { count: { type: "number" } } } })
|
||||
@SwaggerResponse({
|
||||
status: 200,
|
||||
schema: { type: "object", properties: { count: { type: "number" } } },
|
||||
})
|
||||
async resetAllUsageLimits(): Promise<ApiResponse<{ count: number }>> {
|
||||
const result = await this.prisma.usageLimit.updateMany({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user