application.js 344 B

1234567891011121314
  1. 'use strict';
  2. const fs = require('fs/promises');
  3. module.exports = {
  4. async readConfig(path) {
  5. try {
  6. const data = await fs.readFile(path);
  7. return JSON.parse(data);
  8. } catch (error) {
  9. const body = { errcode: -1000, errmsg: '读取配置文件失败', error };
  10. throw new Error(JSON.stringify(body));
  11. }
  12. },
  13. };