feat: resolve attachment user through cfw-auth binding

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-07-02 07:34:48 -07:00
parent fb7afb69f3
commit c4a1b167a1
3 changed files with 97 additions and 0 deletions

33
src/problem.ts Normal file
View File

@@ -0,0 +1,33 @@
export class HttpProblem extends Error {
constructor(
readonly status: number,
readonly code: string,
message: string,
readonly detail: Record<string, unknown> = {},
) {
super(message);
}
}
export function problemResponse(error: unknown): Response {
const problem =
error instanceof HttpProblem
? error
: new HttpProblem(500, "internal-error", "Internal server error");
return Response.json(
{
type: `https://cfw-attachment.bowong.cc/problems/${problem.code}`,
title: problem.message,
status: problem.status,
detail: problem.detail,
code: problem.code,
},
{
status: problem.status,
headers: {
"content-type": "application/problem+json",
},
},
);
}