obs-ss-plugin-webui/lib/apiClient.ts
Decobus 5789986bb6
Some checks failed
Lint and Build / build (22) (pull_request) Failing after 32s
Lint and Build / build (20) (pull_request) Failing after 34s
Add OBS group management feature and documentation
- 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>
2025-07-20 00:28:16 -04:00

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' }),
};