Complete Next.js application for managing OBS Source Switcher - Stream management with multiple screen layouts - Team management CRUD operations - SQLite database integration - OBS WebSocket API integration - Updated to latest versions (Next.js 15.4.1, React 19.1.0, Tailwind CSS 4.0.0) - Enhanced .gitignore for privacy and development
38 lines
1 KiB
TypeScript
38 lines
1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getDatabase } from '../../../lib/database';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
// Extract the team_id from the query string
|
|
const { searchParams } = new URL(request.url);
|
|
const teamId = searchParams.get('team_id');
|
|
|
|
if (!teamId) {
|
|
return NextResponse.json(
|
|
{ error: 'Missing team_id' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const db = await getDatabase();
|
|
const team = await db.get(
|
|
'SELECT team_name FROM teams_2025_spring_adr WHERE team_id = ?',
|
|
[teamId]
|
|
);
|
|
|
|
if (!team) {
|
|
return NextResponse.json(
|
|
{ error: 'Team not found' },
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
return NextResponse.json({ team_name: team.team_name });
|
|
} catch (error) {
|
|
console.error('Error fetching team name:', error instanceof Error ? error.message : String(error));
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch team name' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|