using avatar instead of image & pre-commit

This commit is contained in:
jojopirker
2023-01-04 15:13:08 +01:00
parent b24bfd1d74
commit dba693ee85
2 changed files with 115 additions and 104 deletions
+23 -25
View File
@@ -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;