export type LoginRequest = Record; export type CreateApiRestAuthLoginArgs = {body: LoginRequest}; export type CreateApiRestAuthLoginOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /rest/auth/login */ export const createApiRestAuthLogin = async (args: CreateApiRestAuthLoginArgs, options?: CreateApiRestAuthLoginOptions) => { const {baseUrl = "http://172.18.0.2:3333", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/rest/auth/login${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };