This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/health-check/src/db.js

14 lines
420 B
JavaScript
Raw Normal View History

2020-09-09 12:25:00 +00:00
const fs = require("fs");
const low = require("lowdb");
const FileSync = require("lowdb/adapters/FileSync");
const Memory = require("lowdb/adapters/Memory");
2020-09-09 12:25:00 +00:00
if (!fs.existsSync("state")) fs.mkdirSync("state");
const adapter = process.env.NODE_ENV === "production" ? new FileSync("state/state.json") : new Memory();
const db = low(adapter);
2020-09-09 12:25:00 +00:00
db.defaults({ disabled: false, entries: [] }).write();
module.exports = db;