mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Refactor authentication API service to TypeScript
This commit is contained in:
@@ -5,3 +5,55 @@ declare global {
|
||||
}
|
||||
|
||||
export const API_BASE_URL = window.API_BASE_URL;
|
||||
|
||||
/**
|
||||
* User role in the system
|
||||
*/
|
||||
export enum UserRole {
|
||||
Admin = 'admin',
|
||||
Editor = 'editor',
|
||||
Viewer = 'viewer'
|
||||
}
|
||||
|
||||
/**
|
||||
* User model from the API
|
||||
*/
|
||||
export interface User {
|
||||
id: number;
|
||||
email: string;
|
||||
displayName?: string;
|
||||
role: UserRole;
|
||||
createdAt: string;
|
||||
lastWorkspaceId: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error response from the API
|
||||
*/
|
||||
export interface ErrorResponse {
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login request parameters
|
||||
*/
|
||||
export interface LoginRequest {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login response from the API
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
user: User;
|
||||
sessionId: string;
|
||||
expiresAt: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API call options extending the standard RequestInit
|
||||
*/
|
||||
export interface ApiCallOptions extends RequestInit {
|
||||
headers?: HeadersInit;
|
||||
}
|
||||
Reference in New Issue
Block a user