a70f0c52a9
CI / test (pull_request) Failing after 8s
- Added CORS handling for the create-chat-conversation function. - Implemented health check endpoint for the function. - Created endpoints for managing conversations and messages with OpenAI. - Added error handling and response formatting for better API usability. - Introduced utility functions for environment variable management and Supabase client creation. - Enhanced schema handling for structured responses from OpenAI. - Implemented conversation archiving and retrieval logic.
32 lines
560 B
TypeScript
32 lines
560 B
TypeScript
export class HttpError extends Error {
|
|
status: number;
|
|
code: string;
|
|
details?: unknown;
|
|
|
|
constructor(
|
|
status: number,
|
|
code: string,
|
|
message: string,
|
|
details?: unknown,
|
|
) {
|
|
super(message);
|
|
this.status = status;
|
|
this.code = code;
|
|
this.details = details;
|
|
}
|
|
}
|
|
|
|
export function jsonResponse(
|
|
body: unknown,
|
|
status = 200,
|
|
headers: HeadersInit = {},
|
|
) {
|
|
return new Response(JSON.stringify(body), {
|
|
status,
|
|
headers: {
|
|
"content-type": "application/json; charset=utf-8",
|
|
...headers,
|
|
},
|
|
});
|
|
}
|