GitHub Actions
Deploy from GitHub Actions [dev] - 2025-10-31 07:28:50
68f7925
import { NextResponse } from 'next/server';
export async function GET(request: Request) {
try {
// 簡単な認証チェック(本番環境では適切な認証を実装)
const authHeader = request.headers.get('authorization');
const adminToken = process.env.ADMIN_TOKEN;
if (adminToken && authHeader !== `Bearer ${adminToken}`) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// 動的インポートでプールインスタンスを取得(gradio.tsと同じ方法)
const { getConnectionPool } = await import('@/services/gradio-pool');
const pool = getConnectionPool();
const stats = pool.getStats();
// レスポンスヘッダーを設定
const response = NextResponse.json(stats);
response.headers.set('Cache-Control', 'no-cache, no-store, must-revalidate');
return response;
} catch (error: unknown) {
const err = error as Error;
console.error('[API] Error getting pool stats:', err);
return NextResponse.json({ error: 'Failed to get pool statistics', message: err.message }, { status: 500 });
}
}