We do a little API instability

This commit is contained in:
regalijan 2023-10-19 16:50:56 -04:00
parent 1123b86a47
commit a5bf9fc329
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -26,14 +26,29 @@ export async function onRequestGet(context: RequestContext) {
if (!users.length) return jsonError("No user found with that name", 400);
return jsonResponse(
JSON.stringify(
(await queryLogs(users[0].id, context)).sort((a, b) =>
const thumbnailRequest = await fetch(
`https://thumbnails.roblox.com/v1/users/avatar?format=Png&size=250x250&userIds=${users[0].id}`,
);
const response = {
history: (await queryLogs(users[0].id, context)).sort((a, b) =>
a.entity.properties.executed_at.integerValue >
b.entity.properties.executed_at.integerValue
? 1
: -1,
),
),
);
user: {
avatar: thumbnailRequest.ok
? (
(await thumbnailRequest.json()) as {
data: { imageUrl: string }[];
}
).data[0].imageUrl
: null,
id: users[0].id,
name: users[0].name,
},
};
return jsonResponse(JSON.stringify(response));
}