30 lines
665 B
TypeScript
30 lines
665 B
TypeScript
import type { DirectoryEntry } from '~/types';
|
|
import type { Warren } from '~/types/warrens';
|
|
|
|
export async function getWarrens(): Promise<Record<string, Warren>> {
|
|
const arr: Warren[] = await $fetch(getApiUrl('warrens'), {
|
|
method: 'GET',
|
|
});
|
|
|
|
const warrens: Record<string, Warren> = {};
|
|
|
|
for (const warren of arr) {
|
|
warrens[warren.id] = warren;
|
|
}
|
|
|
|
return warrens;
|
|
}
|
|
|
|
export async function getWarrenDirectory(
|
|
path: string
|
|
): Promise<DirectoryEntry[]> {
|
|
const entries: DirectoryEntry[] = await $fetch(
|
|
getApiUrl(`warrens/${path}`),
|
|
{
|
|
method: 'GET',
|
|
}
|
|
);
|
|
|
|
return entries;
|
|
}
|