mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-17 11:13:32 +08:00
using avatar instead of image & pre-commit
This commit is contained in:
@@ -1,34 +1,32 @@
|
||||
import { boolean } from "boolean";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
|
||||
|
||||
const handler = async (req, res) => {
|
||||
const token = await getToken({ req });
|
||||
const token = await getToken({ req });
|
||||
|
||||
// Return nothing if the user isn't registered.
|
||||
if (!token) {
|
||||
res.status(401).end();
|
||||
return;
|
||||
}
|
||||
// Return nothing if the user isn't registered.
|
||||
if (!token) {
|
||||
res.status(401).end();
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: add params if needed
|
||||
const reqParams = req.query;
|
||||
console.log(reqParams);
|
||||
const params = new URLSearchParams({
|
||||
username: boolean(reqParams.allUsers)? "" : token.sub,
|
||||
});
|
||||
console.log(params);
|
||||
const messagesRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/messages?${params}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"X-API-Key": process.env.FASTAPI_KEY,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},);
|
||||
const messages = await messagesRes.json();
|
||||
//TODO: add params if needed
|
||||
const reqParams = req.query;
|
||||
const params = new URLSearchParams({
|
||||
username: boolean(reqParams.allUsers) ? "" : token.sub,
|
||||
});
|
||||
|
||||
// Send recieved messages to the client.
|
||||
res.status(200).json(messages);
|
||||
}
|
||||
const messagesRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/messages?${params}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"X-API-Key": process.env.FASTAPI_KEY,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
const messages = await messagesRes.json();
|
||||
|
||||
// Send recieved messages to the client.
|
||||
res.status(200).json(messages);
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
||||
Reference in New Issue
Block a user