mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-26 15:39:48 +00:00
Dont use promises for dummy endpoints
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user