2015-10-01 00:30:16 +02:00

96 lines
2.3 KiB
JavaScript
Executable File

'use strict';
/**
* Module dependencies
*/
// 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,
// Default paths.
paths: {
tmp: '.tmp',
admin: 'admin',
config: 'config',
static: 'public',
views: 'views',
controllers: 'api/controllers',
services: 'api/services',
policies: 'api/policies',
models: 'api/models',
templates: 'api/templates',
modules: 'modules'
},
// Add the dashboard URL.
saas: {
url: 'http://dashboard.strapi.io'
},
// Start off needed empty objects.
supports: {},
routes: {}
};
};
/**
* Load the configuration modules
*
* @api private
*/
this.load = require('./load')(strapi);
// Bind the context of all instance methods.
_.bindAll(this);
}
};