fix: add default limit to search query
Signed-off-by: Federico Morreale <frc.morreale@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-search-backend': patch
|
||||
---
|
||||
|
||||
Set the default length limit to search query to 100. To override it, define `search.maxTermLength` in the config file.
|
||||
@@ -63,6 +63,7 @@ export type RouterOptions = {
|
||||
};
|
||||
|
||||
const defaultMaxPageLimit = 100;
|
||||
const defaultMaxTermLength = 100;
|
||||
const allowedLocationProtocols = ['http:', 'https:'];
|
||||
|
||||
/**
|
||||
@@ -77,8 +78,11 @@ export async function createRouter(
|
||||
const maxPageLimit =
|
||||
config.getOptionalNumber('search.maxPageLimit') ?? defaultMaxPageLimit;
|
||||
|
||||
const maxTermLength =
|
||||
config.getOptionalNumber('search.maxTermLength') ?? defaultMaxTermLength;
|
||||
|
||||
const requestSchema = z.object({
|
||||
term: z.string().default(''),
|
||||
term: z.string().max(maxTermLength).default(''),
|
||||
filters: jsonObjectSchema.optional(),
|
||||
types: z
|
||||
.array(z.string().refine(type => Object.keys(types).includes(type)))
|
||||
|
||||
Reference in New Issue
Block a user