mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-11 11:13:12 +08:00
25 lines
686 B
TypeScript
25 lines
686 B
TypeScript
import { withoutRole } from "src/lib/auth";
|
|
import { getBackendUserCore } from "src/lib/users";
|
|
|
|
const handler = withoutRole("banned", async (req, res, token) => {
|
|
//TODO: add params if needed
|
|
const user = await getBackendUserCore(token.sub);
|
|
const params = new URLSearchParams({
|
|
username: user.id,
|
|
auth_method: user.auth_method,
|
|
});
|
|
|
|
const messagesRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/messages?${params}`, {
|
|
method: "GET",
|
|
headers: {
|
|
"X-API-Key": process.env.FASTAPI_KEY,
|
|
},
|
|
});
|
|
const messages = await messagesRes.json();
|
|
|
|
// Send recieved messages to the client.
|
|
res.status(200).json(messages);
|
|
});
|
|
|
|
export default handler;
|