Ghost/core/server/config/index.js
Katharina Irrgang d81bc91bd2 Error creation (#7477)
refs #7116, refs #2001

- Changes the way Ghost errors are implemented to benefit from proper inheritance
- Moves all error definitions into a single file
- Changes the error constructor to take an options object, rather than needing the arguments to be passed in the correct order.
- Provides a wrapper so that any errors that haven't already been converted to GhostErrors get converted before they are displayed.

Summary of changes:

* 🐛  set NODE_ENV in config handler
*   add GhostError implementation (core/server/errors.js)
  - register all errors in one file
  - inheritance from GhostError
  - option pattern
* 🔥  remove all error files
*   wrap all errors into GhostError in case of HTTP
* 🎨  adaptions
  - option pattern for errors
  - use GhostError when needed
* 🎨  revert debug deletion and add TODO for error id's
2016-10-06 13:27:35 +01:00

44 lines
1.1 KiB
JavaScript

var nconf = require('nconf'),
path = require('path'),
localUtils = require('./utils'),
packageInfo = require('../../../package.json'),
env = process.env.NODE_ENV || 'development';
/**
* command line arguments
*/
nconf.argv();
/**
* env arguments
*/
nconf.env();
/**
* load config files
* @TODO:
* - why does this work? i have no idea!
* - find out why argv override works, when defining these weird keys
* - i could not find any nconf usages so that all config requirements work
*/
nconf.file('ghost1', __dirname + '/overrides.json');
nconf.file('ghost2', path.join(process.cwd(), 'config.' + env + '.json'));
nconf.file('ghost3', __dirname + '/env/config.' + env + '.json');
nconf.file('ghost4', __dirname + '/defaults.json');
/**
* transform all relative paths to absolute paths
*/
localUtils.makePathsAbsolute.bind(nconf)();
/**
* values we have to set manual
* @TODO: ghost-cli?
*/
nconf.set('ghostVersion', packageInfo.version);
nconf.set('env', env);
module.exports = nconf;
module.exports.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
module.exports.getContentPath = localUtils.getContentPath.bind(nconf);