- Update streams API to join with teams table and return StreamWithTeam data - Modify stream lookup maps to generate proper stream group names with team prefixes - Format: {team_name}_{stream_name}_stream to match obsClient.js logic - Update type signatures throughout to support team_name and group_name fields - Now properly matches text file contents with database streams for dropdown selection 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
24 lines
795 B
TypeScript
24 lines
795 B
TypeScript
import { NextResponse } from 'next/server';
|
|
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);
|