summaryrefslogtreecommitdiff
path: root/src/misc/keypair-store.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/keypair-store.ts')
-rw-r--r--src/misc/keypair-store.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/misc/keypair-store.ts b/src/misc/keypair-store.ts
new file mode 100644
index 0000000000..c78fdd7555
--- /dev/null
+++ b/src/misc/keypair-store.ts
@@ -0,0 +1,10 @@
+import { UserKeypairs } from '../models';
+import { User } from '../models/entities/user';
+import { UserKeypair } from '../models/entities/user-keypair';
+import { Cache } from './cache';
+
+const cache = new Cache<UserKeypair>(Infinity);
+
+export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
+ return await cache.fetch(userId, () => UserKeypairs.findOneOrFail(userId));
+}