@@ -4,12 +4,12 @@ import { extname, join } from 'node:path'
44import { parseArgs } from 'node:util'
55
66import { 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'
910import { PackageJson } from 'type-fest'
1011
1112import { createApp } from './app.js'
12- import { JSON5File } from './JSON5File.js'
1313import { Observer } from './Observer.js'
1414import { Data } from './service.js'
1515
@@ -64,9 +64,12 @@ const port = parseInt(values.port ?? process.env['PORT'] ?? '3000')
6464const host = values . host ?? process . env [ 'HOST' ] ?? 'localhost'
6565
6666// Set up database
67- let adapter : JSONFile < Data > | JSON5File < Data >
67+ let adapter : Adapter < Data >
6868if ( 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