Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/web/src/app/api/__tests__/realtime-session-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import { GET, POST } from '@/app/api/realtime/session/route';
const ORIGINAL_OPENAI_KEY = process.env.OPENAI_API_KEY;
const ORIGINAL_SAFETY_IDENTIFIER = process.env.OPENAI_SAFETY_IDENTIFIER;

function sdpRequest(body: string) {
function sdpRequest(body: string): Request {
return new Request('http://localhost/api/realtime/session', {
method: 'POST',
headers: { 'content-type': 'application/sdp' },
body,
});
}

function upstreamResponse(body: unknown, status = 200, headers: HeadersInit = { 'content-type': 'application/json' }) {
function upstreamResponse(
body: unknown,
status = 200,
headers: HeadersInit = { 'content-type': 'application/json' },
): Response {
return new Response(typeof body === 'string' ? body : JSON.stringify(body), {
status,
headers,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/realtime/session/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function upstreamUnreachable(
return Response.json({ error, code }, { status: 502 });
}

function getOpenAiHeaders(contentType?: string) {
function getOpenAiHeaders(contentType?: string): Record<string, string> | null {
const apiKey = process.env.OPENAI_API_KEY;

if (!apiKey) {
Expand Down
Loading