sharkey/src/misc/keypair-store.ts

11 lines
399 B
TypeScript
Raw Normal View History

import { UserKeypairs } from '@/models/index';
import { User } from '@/models/entities/user';
import { UserKeypair } from '@/models/entities/user-keypair';
import { Cache } from './cache';
2021-03-22 15:14:54 +09:00
const cache = new Cache<UserKeypair>(Infinity);
export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
2021-03-22 15:16:45 +09:00
return await cache.fetch(userId, () => UserKeypairs.findOneOrFail(userId));
2021-03-22 15:14:54 +09:00
}