({ request }: LoaderFunctionArgs)
| 37 | } |
| 38 | |
| 39 | export async function loader({ request }: LoaderFunctionArgs) { |
| 40 | await requireUserWithRole(request, 'admin') |
| 41 | const searchParams = new URL(request.url).searchParams |
| 42 | const query = searchParams.get('query') |
| 43 | if (query === '') { |
| 44 | searchParams.delete('query') |
| 45 | return redirect(`/admin/cache?${searchParams.toString()}`) |
| 46 | } |
| 47 | const limit = Number(searchParams.get('limit') ?? 100) |
| 48 | |
| 49 | const currentInstanceInfo = await getInstanceInfo() |
| 50 | const instance = |
| 51 | searchParams.get('instance') ?? currentInstanceInfo.currentInstance |
| 52 | const instances = await getAllInstances() |
| 53 | await ensureInstance(instance) |
| 54 | |
| 55 | let cacheKeys: { sqlite: Array<string>; lru: Array<string> } |
| 56 | if (typeof query === 'string') { |
| 57 | cacheKeys = await searchCacheKeys(query, limit) |
| 58 | } else { |
| 59 | cacheKeys = await getAllCacheKeys(limit) |
| 60 | } |
| 61 | return json({ cacheKeys, instance, instances, currentInstanceInfo }) |
| 62 | } |
| 63 | |
| 64 | export async function action({ request }: ActionFunctionArgs) { |
| 65 | await requireUserWithRole(request, 'admin') |
nothing calls this directly
no test coverage detected