feat: site institucional completo com design system - Implementa\u00e7\u00e3o do site institucional da Aggios com design system completo incluindo gradientes, tipografia, componentes e se\u00e7\u00f5es de recursos, pre\u00e7os e CTA
This commit is contained in:
53
front-end-dash.aggios.app/lib/api.ts
Normal file
53
front-end-dash.aggios.app/lib/api.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* API Configuration - URLs e funções de requisição
|
||||
*/
|
||||
|
||||
// URL base da API - pode ser alterada por variável de ambiente
|
||||
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://api.localhost';
|
||||
|
||||
/**
|
||||
* Endpoints da API
|
||||
*/
|
||||
export const API_ENDPOINTS = {
|
||||
// Auth
|
||||
register: `${API_BASE_URL}/api/auth/register`,
|
||||
login: `${API_BASE_URL}/api/auth/login`,
|
||||
logout: `${API_BASE_URL}/api/auth/logout`,
|
||||
refresh: `${API_BASE_URL}/api/auth/refresh`,
|
||||
me: `${API_BASE_URL}/api/me`,
|
||||
|
||||
// Health
|
||||
health: `${API_BASE_URL}/health`,
|
||||
apiHealth: `${API_BASE_URL}/api/health`,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Wrapper para fetch com tratamento de erros
|
||||
*/
|
||||
export async function apiRequest<T = any>(
|
||||
url: string,
|
||||
options?: RequestInit
|
||||
): Promise<T> {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || `Erro ${response.status}`);
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw error;
|
||||
}
|
||||
throw new Error('Erro desconhecido na requisição');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user