UNPKG

i18n-node-server

Version:

NodeJS http server to store your internationalized phrases

18 lines (13 loc) 358 B
import { readFileSync } from "fs"; import { FILE_NOT_FOUND } from "./errors"; import { Records } from "./fs-service"; export class FileReader { static readFile(path: string): Records | Error { try { const data = readFileSync(path).toString("utf-8"); return JSON.parse(data); } catch (err) { return FILE_NOT_FOUND; } } }