Handle 404 for user accounts

This commit is contained in:
Zoe Roux 2025-04-07 12:38:48 +02:00
parent b3edf31afc
commit 59533e5f0c
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { TypeCompiler } from "@sinclair/typebox/compiler";
import Elysia, { t } from "elysia";
import { createRemoteJWKSet, jwtVerify } from "jose";
import { KError } from "./models/error";
const jwtSecret = process.env.JWT_SECRET
? new TextEncoder().encode(process.env.JWT_SECRET)
@ -86,7 +87,7 @@ const User = t.Object({
}),
),
});
const UserC = TypeCompiler.Compile(User);
const UserC = TypeCompiler.Compile(t.Union([User, KError]));
export async function getUserInfo(
id: string,

View File

@ -174,6 +174,15 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
authorization: t.TemplateLiteral("Bearer ${string}"),
"accept-language": AcceptLanguage({ autoFallback: true }),
}),
response: {
200: Page(Show),
403: KError,
404: {
...KError,
description: "No user found with the specified id/username.",
},
422: KError,
},
permissions: ["users.read"],
},
),