mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			101 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
		
			2.4 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 reload config.
 | 
						|
        reload: {
 | 
						|
          timeout: 1000,
 | 
						|
          workers: 1
 | 
						|
        },
 | 
						|
 | 
						|
        // Default paths.
 | 
						|
        paths: {
 | 
						|
          tmp: '.tmp',
 | 
						|
          config: 'config',
 | 
						|
          static: 'public',
 | 
						|
          views: 'views',
 | 
						|
          api: 'api',
 | 
						|
          controllers: 'controllers',
 | 
						|
          services: 'services',
 | 
						|
          policies: 'policies',
 | 
						|
          models: 'models',
 | 
						|
          templates: 'templates'
 | 
						|
        },
 | 
						|
 | 
						|
        // Add the Studio URL.
 | 
						|
        studio: {
 | 
						|
          url: 'http://studio.strapi.io'
 | 
						|
        },
 | 
						|
 | 
						|
        // Start off needed empty objects and strings.
 | 
						|
        routes: {},
 | 
						|
        frontendUrl: ''
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    /**
 | 
						|
     * Load the configuration modules
 | 
						|
     *
 | 
						|
     * @api private
 | 
						|
     */
 | 
						|
 | 
						|
    this.load = require('./load')(strapi);
 | 
						|
 | 
						|
    // Bind the context of all instance methods.
 | 
						|
    _.bindAll(this);
 | 
						|
  }
 | 
						|
};
 |