diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/services/postDatabase.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/services/postDatabase.ts b/src/services/postDatabase.ts index a782af8..0fa741b 100644 --- a/src/services/postDatabase.ts +++ b/src/services/postDatabase.ts | |||
@@ -36,7 +36,12 @@ export class PostDatabase { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | const fileContent = await fs.readFile(this.filePath, "utf8"); | 38 | const fileContent = await fs.readFile(this.filePath, "utf8"); |
39 | const entries = t.array(PostDatabaseEntryC).decode(fileContent); | 39 | const entries = f.function.pipe( |
40 | fileContent, | ||
41 | f.json.parse, | ||
42 | f.either.mapLeft(() => []), | ||
43 | f.either.chain(t.array(PostDatabaseEntryC).decode) | ||
44 | ); | ||
40 | 45 | ||
41 | if (f.either.isRight(entries)) { | 46 | if (f.either.isRight(entries)) { |
42 | this.entries = this.max ? entries.right.slice(-1 * this.max) : entries.right; | 47 | this.entries = this.max ? entries.right.slice(-1 * this.max) : entries.right; |