@xsprtd/nuxt-api
Version:
Nuxt API Authentication and Http Client
18 lines (17 loc) • 744 B
TypeScript
import type { FetchOptions } from 'ofetch';
import type { ComputedRef, Ref } from 'vue';
import type { RouteLocationRaw } from 'vue-router';
import type { ErrorBagInterface } from './Http.js';
export interface AuthCheckResult {
isAuthenticated: boolean;
redirectTo: RouteLocationRaw | null;
}
export interface Auth<T> {
user: Ref<T | null>;
isLoggedIn: ComputedRef<boolean>;
refreshUser: () => Promise<void>;
login: <LoginApiResponse>(credentials: Record<string, string>, clientOptions?: FetchOptions, callback?: (responseData: LoginApiResponse, user: T | null) => unknown) => Promise<unknown>;
logout: (callback?: () => unknown) => Promise<unknown>;
processing: Ref<boolean>;
errorBag: ErrorBagInterface;
}