From af5724f3c15e7bc0f075870751b10d1c9dc4268c Mon Sep 17 00:00:00 2001 From: ccbikai Date: Wed, 25 Dec 2024 12:14:38 +0800 Subject: [PATCH] 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. --- nuxt.config.ts | 1 + schemas/query.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 2615408..ab6d26b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -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', diff --git a/schemas/query.ts b/schemas/query.ts index dceadc1..fae9258 100644 --- a/schemas/query.ts +++ b/schemas/query.ts @@ -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({