summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/services/postDatabase.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/services/postDatabase.ts b/src/services/postDatabase.ts
index 63227a2..a782af8 100644
--- a/src/services/postDatabase.ts
+++ b/src/services/postDatabase.ts
@@ -2,6 +2,7 @@ import fs from "fs/promises";
2import path from "path"; 2import path from "path";
3import * as f from "fp-ts"; 3import * as f from "fp-ts";
4import * as t from "io-ts"; 4import * as t from "io-ts";
5import * as tr from "io-ts/PathReporter";
5 6
6export const PostDatabaseEntryC = t.type({ 7export const PostDatabaseEntryC = t.type({
7 provider: t.literal("e926"), 8 provider: t.literal("e926"),
@@ -39,6 +40,8 @@ export class PostDatabase {
39 40
40 if (f.either.isRight(entries)) { 41 if (f.either.isRight(entries)) {
41 this.entries = this.max ? entries.right.slice(-1 * this.max) : entries.right; 42 this.entries = this.max ? entries.right.slice(-1 * this.max) : entries.right;
43 } else {
44 throw new Error(tr.failure(entries.left).join("\n\n"));
42 } 45 }
43 } 46 }
44 47
@@ -78,11 +81,6 @@ export class PostDatabase {
78 await this.save(); 81 await this.save();
79 return true; 82 return true;
80 } 83 }
81
82 async getCount() {
83 await this.load();
84 return this.entries.length;
85 }
86} 84}
87 85
88export default PostDatabase; 86export default PostDatabase;