import { promises as fs } from 'node:fs' import { accountJsonPath } from './paths.js' export interface Account { id: string password: string } /** account.json 에서 로그인 계정 목록을 읽는다. (나머지 파일 기반 저장소는 storeDb.ts 로 이전됨.) */ export async function readAccounts(): Promise { try { const raw = await fs.readFile(accountJsonPath, 'utf8') const parsed = JSON.parse(raw) if (!Array.isArray(parsed)) return [] return parsed.filter( (entry): entry is Account => typeof entry?.id === 'string' && typeof entry?.password === 'string' ) } catch (err) { if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [] throw err } }