Skip to main content
Glama
auth.ts1.11 kB
/** * User Authentication Service * TypeScript frontend component */ export interface User { id: number; email: string; name: string; } /** * Authentication service for managing user sessions */ export class AuthService { private apiUrl: string; /** * Creates a new AuthService instance * @param apiUrl - The API base URL */ constructor(apiUrl: string) { this.apiUrl = apiUrl; } /** * Logs in a user with email and password * @param email - User email address * @param password - User password * @returns Promise with user data or null */ async login(email: string, password: string): Promise<User | null> { try { const response = await fetch(`${this.apiUrl}/auth/login`, { method: 'POST', body: JSON.stringify({ email, password }) }); return await response.json(); } catch (error) { console.error('Login failed:', error); return null; } } /** * Logs out the current user */ async logout(): Promise<void> { await fetch(`${this.apiUrl}/auth/logout`, { method: 'POST' }); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LiL-Loco/documentation-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server