forked from RiseUP/riseup-squad18
22 lines
530 B
TypeScript
22 lines
530 B
TypeScript
export function corsHeaders() {
|
|
return {
|
|
"Access-Control-Allow-Origin": "*",
|
|
"Access-Control-Allow-Headers":
|
|
"authorization, x-client-info, apikey, content-type",
|
|
};
|
|
}
|
|
|
|
export function jsonResponse(data: any, status: number = 200) {
|
|
return new Response(JSON.stringify(data), {
|
|
status,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...corsHeaders(),
|
|
},
|
|
});
|
|
}
|
|
|
|
export function errorResponse(message: string, status: number = 500) {
|
|
return jsonResponse({ error: message }, status);
|
|
}
|