All checks were successful
Lint and Build / build (pull_request) Successful in 2m47s
- Remove unused NextResponse imports from API routes - Remove unused result variable in teams DELETE route - Remove unused Link import from page.tsx - Remove unused inspectTextSourceProperties function from obsClient.js - Fix unused catch variables and response variables in test files - Clean up all ESLint warnings for unused variables
23 lines
751 B
TypeScript
23 lines
751 B
TypeScript
import { getDatabase } from '../../../lib/database';
|
|
import { StreamWithTeam } from '@/types';
|
|
import { TABLE_NAMES } from '../../../lib/constants';
|
|
import { createSuccessResponse, createDatabaseError, withErrorHandling } from '../../../lib/apiHelpers';
|
|
|
|
async function getStreamsHandler() {
|
|
try {
|
|
const db = await getDatabase();
|
|
const streams: StreamWithTeam[] = await db.all(`
|
|
SELECT
|
|
s.*,
|
|
t.team_name,
|
|
t.group_name
|
|
FROM ${TABLE_NAMES.STREAMS} s
|
|
LEFT JOIN ${TABLE_NAMES.TEAMS} t ON s.team_id = t.team_id
|
|
`);
|
|
return createSuccessResponse(streams);
|
|
} catch (error) {
|
|
return createDatabaseError('fetch streams', error);
|
|
}
|
|
}
|
|
|
|
export const GET = withErrorHandling(getStreamsHandler);
|