list warrens + explore nested folders
This commit is contained in:
29
frontend/lib/api/warrens.ts
Normal file
29
frontend/lib/api/warrens.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user