mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
refactor(schema): simplify validation and OpenAPI generation (#2709)
This commit is contained in:
1 parent
4bc5593f9f
commit
de1fd95a99
510 files changed
+29494
-36131
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type {ErrorResponse} from '@fluxer/schema/src/domains/common/ErrorSchemas';
|
||||
import {HTTPException} from 'hono/http-exception';
|
||||
|
||||
export type FluxerErrorData = Record<string, unknown>;
|
||||
@@ -36,23 +37,16 @@ export class FluxerError extends HTTPException {
|
||||
}
|
||||
|
||||
override getResponse(): Response {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
code: this.code,
|
||||
message: this.message,
|
||||
...this.data,
|
||||
}),
|
||||
{
|
||||
status: this.status,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...this.headers,
|
||||
},
|
||||
return new Response(JSON.stringify(this.toJSON()), {
|
||||
status: this.status,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...this.headers,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
toJSON(): Record<string, unknown> {
|
||||
toJSON(): ErrorResponse {
|
||||
return {
|
||||
code: this.code,
|
||||
message: this.message,
|
||||
|
||||
Reference in new issue
Block a user