Dont use promises for dummy endpoints

This commit is contained in:
Rory&
2025-12-19 20:32:26 +01:00
parent c57f02f05c
commit 9d4e3d39f4
38 changed files with 47 additions and 47 deletions
+2 -2
View File
@@ -43,8 +43,8 @@ export class DmChannelDTO {
await Promise.all(
channel.recipients
?.filter((r) => !excluded_recipients.includes(r.user_id))
.map(async (r) => {
return await User.findOneOrFail({
.map((r) => {
return User.findOneOrFail({
where: { id: r.user_id },
select: PublicUserProjection,
});
+1 -1
View File
@@ -55,7 +55,7 @@ export async function generateWebAuthnTicket(challenge: string): Promise<string>
export async function verifyWebAuthnToken(token: string) {
return new Promise((res, rej) => {
loadOrGenerateKeypair().then((kp) =>
jwt.verify(token, kp.publicKey, jwtVerifyOptions, async (err, decoded) => {
jwt.verify(token, kp.publicKey, jwtVerifyOptions, (err, decoded) => {
if (err) return rej(err);
return res(decoded);
}),
@@ -16,11 +16,12 @@ export class IpDataClient {
if (this.ipInfoCache.get(ip)?.expires ?? 0 > Date.now()) return this.ipInfoCache.get(ip)!.data;
console.log(`[IpData] Fetching info for IP address ${ip}...`);
const resp = (await (await fetch(`https://eu-api.ipdata.co/${ip}?api-key=${ipdataApiKey}`)).json()) as Promise<IpDataIpLookupResponse>;
const response = await fetch(`https://eu-api.ipdata.co/${ip}?api-key=${ipdataApiKey}`);
const data = (await response.json()) as IpDataIpLookupResponse;
this.ipInfoCache.set(ip, {
data: await resp,
data: data,
expires: new DateBuilder().addHours(12).buildTimestamp(),
});
return await resp;
return data;
}
}