feat: add configurable list query limit

Extracts list query limit into runtime configuration
Updates default pagination limit in query schema

Makes the list query limit configurable across the application rather than hardcoding it to 500, improving flexibility for different deployment scenarios.
This commit is contained in:
ccbikai 2024-12-25 12:14:38 +08:00
parent 5abc4af3f5
commit af5724f3c1
2 changed files with 4 additions and 1 deletions

View file

@ -26,6 +26,7 @@ export default defineNuxtConfig({
aiModel: '@cf/meta/llama-3.1-8b-instruct',
aiPrompt: `You are a URL shortening assistant, please shorten the URL provided by the user into a SLUG. The SLUG information must come from the URL itself, do not make any assumptions. A SLUG is human-readable and should not exceed three words and can be validated using regular expressions {slugRegex} . Only the best one is returned, the format must be JSON reference {"slug": "example-slug"}`,
caseSensitive: false,
listQueryLimit: 500,
public: {
previewMode: '',
slugDefaultLength: '6',

View file

@ -1,5 +1,7 @@
import { z } from 'zod'
const listQueryLimit = +useRuntimeConfig().listQueryLimit
export const QuerySchema = z.object({
id: z.string().optional(),
startAt: z.coerce.number().int().safe().optional(),
@ -17,7 +19,7 @@ export const QuerySchema = z.object({
browserType: z.string().optional(),
device: z.string().optional(),
deviceType: z.string().optional(),
limit: z.coerce.number().int().safe().default(500),
limit: z.coerce.number().int().safe().default(listQueryLimit),
})
export const FilterSchema = QuerySchema.omit({ id: true, startAt: true, endAt: true, limit: true }).extend({