2023-01-13 05:40:33 +01:00
|
|
|
import { UserKeypairs } from "@/models/index.js";
|
|
|
|
import type { User } from "@/models/entities/user.js";
|
|
|
|
import type { UserKeypair } from "@/models/entities/user-keypair.js";
|
|
|
|
import { Cache } from "./cache.js";
|
2021-03-22 07:14:54 +01:00
|
|
|
|
|
|
|
const cache = new Cache<UserKeypair>(Infinity);
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
export async function getUserKeypair(userId: User["id"]): Promise<UserKeypair> {
|
|
|
|
return await cache.fetch(userId, () =>
|
|
|
|
UserKeypairs.findOneByOrFail({ userId: userId }),
|
|
|
|
);
|
2021-03-22 07:14:54 +01:00
|
|
|
}
|