Skip to content

Commit 34f881d

Browse files
committed
chore: update lowdb version to 7.0.1 and simplify code
1 parent 2b84950 commit 34f881d

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"eta": "^3.2.0",
4545
"inflection": "^3.0.0",
4646
"json5": "^2.2.3",
47-
"lowdb": "^7.0.0",
47+
"lowdb": "^7.0.1",
4848
"milliparsec": "^2.3.0",
4949
"sirv": "^2.0.4",
5050
"sort-on": "^6.0.0",

src/JSON5File.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/bin.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { extname, join } from 'node:path'
44
import { parseArgs } from 'node:util'
55

66
import { watch } from 'chokidar'
7-
import { Low } from 'lowdb'
8-
import { JSONFile } from 'lowdb/node'
7+
import JSON5 from 'json5'
8+
import { Adapter, Low } from 'lowdb'
9+
import { DataFile, JSONFile } from 'lowdb/node'
910
import { PackageJson } from 'type-fest'
1011

1112
import { createApp } from './app.js'
12-
import { JSON5File } from './JSON5File.js'
1313
import { Observer } from './Observer.js'
1414
import { Data } from './service.js'
1515

@@ -64,9 +64,12 @@ const port = parseInt(values.port ?? process.env['PORT'] ?? '3000')
6464
const host = values.host ?? process.env['HOST'] ?? 'localhost'
6565

6666
// Set up database
67-
let adapter: JSONFile<Data> | JSON5File<Data>
67+
let adapter: Adapter<Data>
6868
if (extname(file) === '.json5') {
69-
adapter = new JSON5File<Data>(file)
69+
adapter = new DataFile<Data>(file, {
70+
parse: JSON5.parse,
71+
stringify: JSON5.stringify,
72+
})
7073
} else {
7174
adapter = new JSONFile<Data>(file)
7275
}

0 commit comments

Comments
 (0)