- Add group_name column to teams table for mapping teams to OBS groups - Create API endpoints for group creation (/api/createGroup) and bulk sync (/api/syncGroups) - Update teams UI with group status display and creation buttons - Implement automatic group assignment when adding streams - Add comprehensive OBS setup documentation (docs/OBS_SETUP.md) - Fix team list spacing issue with explicit margins - Update OBS client with group management functions - Add database migration script for existing deployments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
47 lines
No EOL
1.3 KiB
TypeScript
47 lines
No EOL
1.3 KiB
TypeScript
// API client utility for making authenticated requests
|
|
|
|
// Get API key from environment (client-side will need to be provided differently)
|
|
function getApiKey(): string | null {
|
|
if (typeof window === 'undefined') {
|
|
// Server-side
|
|
return process.env.API_KEY || null;
|
|
} else {
|
|
// Client-side - for now, return null to bypass auth in development
|
|
// In production, this would come from a secure storage or context
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// Authenticated fetch wrapper
|
|
export async function apiCall(url: string, options: RequestInit = {}): Promise<Response> {
|
|
const apiKey = getApiKey();
|
|
|
|
const headers: Record<string, string> = {
|
|
'Content-Type': 'application/json',
|
|
...(options.headers as Record<string, string> || {}),
|
|
};
|
|
|
|
// Add API key if available
|
|
if (apiKey) {
|
|
headers['x-api-key'] = apiKey;
|
|
}
|
|
|
|
return fetch(url, {
|
|
...options,
|
|
headers,
|
|
});
|
|
}
|
|
|
|
// Convenience methods
|
|
export const apiClient = {
|
|
get: (url: string) => apiCall(url, { method: 'GET' }),
|
|
post: (url: string, data: unknown) => apiCall(url, {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
}),
|
|
put: (url: string, data: unknown) => apiCall(url, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
}),
|
|
delete: (url: string) => apiCall(url, { method: 'DELETE' }),
|
|
}; |