feat(api): standardize errors as problem details
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import type { ProblemDetails } from "@minecraft-account-manager/contracts";
|
||||
|
||||
export function problemInstance(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
return `${url.pathname}${url.search}`;
|
||||
}
|
||||
|
||||
export function problemResponse(problem: ProblemDetails) {
|
||||
return new Response(JSON.stringify(problem), {
|
||||
status: problem.status,
|
||||
headers: {
|
||||
"cache-control": "no-store",
|
||||
"content-type": "application/problem+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user