mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): ♻️ Properly reuse error messages and schemas
This commit is contained in:
parent
7112a66e4c
commit
65e2e19ff1
84 changed files with 478 additions and 597 deletions
|
|
@ -13,7 +13,6 @@ import { Users } from "@versia/kit/tables";
|
|||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import { ApiError } from "~/classes/errors/api-error";
|
||||
import { config } from "~/config.ts";
|
||||
import { ErrorSchema } from "~/types/api";
|
||||
|
||||
const schemas = {
|
||||
query: z.object({
|
||||
|
|
@ -46,14 +45,7 @@ const route = createRoute({
|
|||
},
|
||||
},
|
||||
},
|
||||
404: {
|
||||
description: "User not found",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: ErrorSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
404: ApiError.accountNotFound().schema,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -85,7 +77,7 @@ export default apiRoute((app) =>
|
|||
);
|
||||
|
||||
if (!user) {
|
||||
throw new ApiError(404, "User not found");
|
||||
throw ApiError.accountNotFound();
|
||||
}
|
||||
|
||||
let activityPubUrl = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue