/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/utils/src/route-serialization.ts
30 строк
1 KB
Nico André
chore(lint): add non-blocking oxlint setup (#26923)
31 июл 2026, 16:56
Не верифицирован
31 июл 2026, 16:56
6469af3
Код
Авторство
О чём код?
/* * Utility to sanitize content API route objects for safe JSON serialization. * Removes Zod validation fields (request/response) for safe serialization. * * NOTE: some content API routes are returned to the admin panel e.g. to * populate the users and permissions roles page. We need to ensure that the * routes can be serialized to JSON without errors. */ export const sanitizeRouteForSerialization = ({ request: _request, response: _response, ...rest }: Record<string, unknown>) => rest as Record<string, unknown>; export const sanitizeRoutesArrayForSerialization = (routes: unknown[]): Record<string, unknown>[] => routes .filter((route): route is Record<string, unknown> => !!route && typeof route === 'object') .map(sanitizeRouteForSerialization); export const sanitizeRoutesMapForSerialization = ( map: Record<string, unknown[]> ): Record<string, unknown> => Object.entries(map).reduce( (acc, [key, value]) => ({ ...acc, [key]: Array.isArray(value) ? sanitizeRoutesArrayForSerialization(value) : value, }), {} );