diff options
Diffstat (limited to 'src/services/postDatabase.ts')
-rw-r--r-- | src/services/postDatabase.ts | 8 |
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"; | |||
2 | import path from "path"; | 2 | import path from "path"; |
3 | import * as f from "fp-ts"; | 3 | import * as f from "fp-ts"; |
4 | import * as t from "io-ts"; | 4 | import * as t from "io-ts"; |
5 | import * as tr from "io-ts/PathReporter"; | ||
5 | 6 | ||
6 | export const PostDatabaseEntryC = t.type({ | 7 | export 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 | ||
88 | export default PostDatabase; | 86 | export default PostDatabase; |