dipper/src/lib/api/sites.ts

29 lines
743 B
TypeScript

import type { Cookies } from '@sveltejs/kit';
import type { Collection } from './collections';
import { callJSON } from './request';
export interface Site {
name: string;
owner: string;
owner_display_name: string;
title: string;
description: string | null;
collections: Collection[];
default_collection: string;
created_at: string;
modified_at: string | null;
deleted_at: string | null;
}
export interface SiteShortInfo {
name: string;
title: string;
description: string | null;
created_at: string;
}
export const getSiteInfo = (name: string) => callJSON<Site>('GET', `sites/${name}`);
export const getSitesForCurrentUser = (cookies: Cookies) =>
callJSON<SiteShortInfo[]>('GET', 'users/@current/sites', undefined, cookies);