/home/techb158/cosmic-risk.abdallabala.com/src/lib
Edit: /home/techb158/cosmic-risk.abdallabala.com/src/lib/http.js (563B)
function jsonResponse(payload, status = 200, headers = {}) {
return Response.json(payload, {
status,
headers: Object.assign({
"Cache-Control": "no-store"
}, headers)
});
}
function errorResponse(error) {
return jsonResponse({
error: error.message || "Unexpected error",
details: error.details || undefined
}, error.status || 500);
}
async function parseJson(request) {
const text = await request.text();
if (!text) return {};
return JSON.parse(text);
}
module.exports = {
jsonResponse,
errorResponse,
parseJson
};