HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //var/dev/farhangmoaser/web/config.js
'use strict';

var fs = require('fs');
var deepAssign = require('deep-assign');

var confs = JSON.parse(fs.readFileSync(__dirname+'/config.json').toString());

class Config {
  constructor(env) {
    this.env = env;
  }

  read(path) {
    var conf = confs[env];
    if(!path) return conf;
    try {
      path.split('.').forEach(key => conf = conf[key])
      return conf;
    }catch(e) {
      return null;
    }
  }

  write(_confs){
  	confs[global.env] = deepAssign(confs[global.env], _confs);
  	fs.writeFileSync('config.json', JSON.stringify(confs, null, 2));
  }
}
global.env = global.env || process.env.FM_ENV || "production";

// module.exports = confs[global.env];
module.exports = new Config(env);