2015-10-01 00:30:16 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies
|
|
|
|
*/
|
|
|
|
|
2015-11-13 17:04:32 +01:00
|
|
|
// Node.js core.
|
|
|
|
const os = require('os');
|
|
|
|
|
2015-10-01 00:30:16 +02:00
|
|
|
// Public node modules.
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
|
|
// Local dependencies.
|
|
|
|
const DEFAULT_HOOKS = require('./hooks/defaultHooks');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose new instance of `Configuration`
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = function (strapi) {
|
|
|
|
return new Configuration();
|
|
|
|
|
|
|
|
function Configuration() {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Strapi default configuration
|
|
|
|
*
|
|
|
|
* @api private
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.defaults = function defaultConfig(appPath) {
|
|
|
|
|
|
|
|
// If `appPath` not specified, unfortunately, this is a fatal error,
|
|
|
|
// since reasonable defaults cannot be assumed.
|
|
|
|
if (!appPath) {
|
|
|
|
throw new Error('Error: No `appPath` specified!');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up config defaults.
|
|
|
|
return {
|
|
|
|
|
|
|
|
// Core (default) hooks.
|
|
|
|
hooks: _.reduce(DEFAULT_HOOKS, function (memo, hookBundled, hookIdentity) {
|
|
|
|
memo[hookIdentity] = require('./hooks/' + hookIdentity);
|
|
|
|
return memo;
|
|
|
|
}, {}) || {},
|
|
|
|
|
|
|
|
// Save `appPath` in implicit defaults.
|
|
|
|
// `appPath` is passed from above in case `start` was used.
|
|
|
|
// This is the directory where this Strapi process is being initiated from.
|
|
|
|
// Usually this means `process.cwd()`.
|
|
|
|
appPath: appPath,
|
|
|
|
|
|
|
|
// Core settings non provided by hooks.
|
|
|
|
host: process.env.HOST || process.env.HOSTNAME || strapi.config.host || 'localhost',
|
|
|
|
port: process.env.PORT || strapi.config.port || 1337,
|
|
|
|
|
|
|
|
// Make the environment in config match the server one.
|
|
|
|
environment: strapi.app.env || process.env.NODE_ENV,
|
|
|
|
|
2015-11-05 14:25:36 +01:00
|
|
|
// Default reload config.
|
|
|
|
reload: {
|
|
|
|
timeout: 1000,
|
2015-11-13 17:04:32 +01:00
|
|
|
workers: os.cpus().length
|
2015-11-05 14:25:36 +01:00
|
|
|
},
|
|
|
|
|
2015-12-02 14:57:00 +01:00
|
|
|
// Application is not `dry` by default.
|
|
|
|
dry: false,
|
|
|
|
|
2015-10-01 00:30:16 +02:00
|
|
|
// Default paths.
|
|
|
|
paths: {
|
|
|
|
tmp: '.tmp',
|
|
|
|
config: 'config',
|
|
|
|
static: 'public',
|
|
|
|
views: 'views',
|
2015-10-05 18:29:04 +02:00
|
|
|
api: 'api',
|
|
|
|
controllers: 'controllers',
|
|
|
|
services: 'services',
|
|
|
|
policies: 'policies',
|
|
|
|
models: 'models',
|
|
|
|
templates: 'templates'
|
2015-10-01 00:30:16 +02:00
|
|
|
},
|
|
|
|
|
2015-11-05 14:25:36 +01:00
|
|
|
// Start off needed empty objects and strings.
|
|
|
|
routes: {},
|
|
|
|
frontendUrl: ''
|
2015-10-01 00:30:16 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the configuration modules
|
|
|
|
*
|
|
|
|
* @api private
|
|
|
|
*/
|
|
|
|
|
|
|
|
this.load = require('./load')(strapi);
|
|
|
|
|
|
|
|
// Bind the context of all instance methods.
|
|
|
|
_.bindAll(this);
|
|
|
|
}
|
|
|
|
};
|