Creates an *express.js* application with given config but doesn't start it.

@param {Object} config
The config object for a service. See README.md for documentation about config files.

@returns {Object}
Express application instance.
11105
function(config) {
    var app = express();

    app.config = config;

    app.use(function(req, res, next) {
      // express.js seems to store the app in req.app already but it isn't
      // documented anywhere. Just to make sure we do it also.
      req.app = app;
      next();
    });

    if (app.config.protocol === 'spdy') {
      createSpdyServer(app);
    } else if ( app.config.protocol === 'https' ) {
      createHttpsServer(app);
    } else {
      createHttpServer(app);
    }

    log.trace("Initializing features");
    app = plugins.initFeatures(app);
    log.trace("Triggering appReady event");
    app.emit('appReady', app);

    return app;
  }
799637
function createLogger (config) {
  config = config || {}
  let level
  if (process.env.KOOP_LOG_LEVEL) {
    level = process.env.KOOP_LOG_LEVEL
  } else if (process.env.NODE_ENV === 'production') {
    level = 'info'
  } else {
    level = 'debug'
  }

  if (!config.logfile) {
    // no logfile defined, log to STDOUT an STDERRv
    const debugConsole = new winston.transports.Console({
      colorize: process.env.NODE_ENV === 'production',
      level,
      stringify: true,
      json: true
    })
    return new winston.Logger({ transports: [debugConsole] })
  }

  // we need a dir to do log rotation so we get the dir from the file
  const logpath = path.dirname(config.logfile)
  const logAll = new winston.transports.File({
    filename: config.logfile,
    name: 'log.all',
    dirname: logpath,
    colorize: true,
    json: false,
    level,
    formatter: formatter
  })
  const logError = new winston.transports.File({
    filename: config.logfile.replace('.log', '.error.log'),
    name: 'log.error',
    dirname: logpath,
    colorize: true,
    json: false,
    level: 'error',
    formatter: formatter
  })

  // always log errors
  const transports = [logError]
  // only log everthing if debug mode is on
  if (process.env['LOG_LEVEL'] === 'debug') {
    transports.push(logAll)
  }

  return new winston.Logger({ transports })
}
569953
function configureExpress() {

	// create configuration routes
	moduleConfig.express.get( /^\/conf.*/, checkAuth, getPath, getMiddlewareWrapper( onGetConf ) );
	moduleConfig.express.post( /^\/conf.*/, storeRequestBody, checkAuth, getPath, getMiddlewareWrapper( onPostConf ) );
	moduleConfig.express.delete( /^\/conf.*/, checkAuth, getPath, getMiddlewareWrapper( onDeleteConf ) );

	// create auth management routes
	moduleConfig.express.post( "/auth", checkAuth, getMiddlewareWrapper( onPostAuth ) );
	moduleConfig.express.delete( "/auth", checkAuth, getMiddlewareWrapper( onDeleteAuth ) );

}
59901
function(config) {
      tesselKitConfig = config === undefined || config === null ? {} : config;
      module.exports.tesselKitConfig = tesselKitConfig;

      module.exports.generalUtils = require("./general-utils");
      module.exports.logHelper = require("./log-helper");
      module.exports.tesselUtils = require("./tessel-utils");

      module.exports.ButtonMgr = require("./classes/button-mgr");
      module.exports.LedMgr = require("./classes/led-mgr");

      return this;
    }
233700
public static function init($config = null)
    {
        self::registerDevelopmentErrorHandler();
        self::registerExceptionHandler();

        if ($config === null) {
            $config = static::loadAppConfig();
        }

        static::addCoreModule($config);

        $serviceConfig = isset($config['service_manager']) ? $config['service_manager'] : array();
        $listeners = isset($config['listeners'])? $config['listeners'] : array();
        $serviceManager = new ServiceManager(new ServiceConfig($serviceConfig));

        $serviceManager->setService('ApplicationConfig', $config);
        $serviceManager->get('ModuleManager')->loadModules();

        return $serviceManager->get('Application')->bootstrap($listeners);
    }
562371
function(config, name) {
            if (config && config !== Object(config)) {
                throw new Error('Config object should be a key/value object.');
            }

            var defaultConfig = {
                loop: false,
                maxLoops: Infinity
            };

            var instance = Object.create(Queue);

            this.queues.push(name ? {
                name: name,
                instance: instance
            } : {
                instance: instance
            });

            merge(instance, {
                config: merge({}, defaultConfig, config),
                steps: []
            });

            return instance;
        }
1043129
public static function getInstance(Config $config = null) {

		if(is_null(self::$instance)) {
			if(is_null($config)) {
				throw new ApplicationException('No configuration object provided. Cannot instantiate application.');
			}
			self::$instance = new Application($config);
		}

		return self::$instance;

	}
385252
function Builder (config) {
  if (!(config instanceof Config)) {
    config = new Config(config)
  }
  this.config = config
  // TODO: check for root.val
  if (!this.config.native.root) {
    // TODO: simplify this set
    this.config.native.set({
      root: {
        val: process.cwd()
      }
    })
  }
}
318965
public static function createApplication(array $config)
    {
        if (!isset($config['type'])) $config['type'] = 'unsupported';
        if (isset($config['class'])) {
            $className = $config['class'];
            return new $className($config);
        } else switch ($config['type']) {
            case 'web':
                return new WebApplication($config);
            default:
                throw new InvalidPropertyException([EntityType::APPLICATION, 'type']);
        }
    }
1210574
async function start() {
  if (server) return server;
  server = express();
  server.use(errorOverlayMiddleware());
  server.use(express.static(path.resolve(__dirname, '../public')));

  // Configure client-side hot module replacement
  const clientConfig = webpackConfig.find(config => config.name === 'client');
  clientConfig.entry.client = ['./tools/lib/webpackHotDevClient']
    .concat(clientConfig.entry.client)
    .sort((a, b) => b.includes('polyfill') - a.includes('polyfill'));
  clientConfig.output.filename = clientConfig.output.filename.replace(
    'chunkhash',
    'hash',
  );
  clientConfig.output.chunkFilename = clientConfig.output.chunkFilename.replace(
    'chunkhash',
    'hash',
  );
  clientConfig.module.rules = clientConfig.module.rules.filter(
    x => x.loader !== 'null-loader',
  );
  clientConfig.plugins.push(new webpack.HotModuleReplacementPlugin());

  // Configure server-side hot module replacement
  const serverConfig = webpackConfig.find(config => config.name === 'server');
  serverConfig.output.hotUpdateMainFilename = 'updates/[hash].hot-update.json';
  serverConfig.output.hotUpdateChunkFilename =
    'updates/[id].[hash].hot-update.js';
  serverConfig.module.rules = serverConfig.module.rules.filter(
    x => x.loader !== 'null-loader',
  );
  serverConfig.plugins.push(new webpack.HotModuleReplacementPlugin());

  // Configure compilation
  await run(clean);
  const multiCompiler = webpack(webpackConfig);
  const clientCompiler = multiCompiler.compilers.find(
    compiler => compiler.name === 'client',
  );
  const serverCompiler = multiCompiler.compilers.find(
    compiler => compiler.name === 'server',
  );
  const clientPromise = createCompilationPromise(
    'client',
    clientCompiler,
    clientConfig,
  );
  const serverPromise = createCompilationPromise(
    'server',
    serverCompiler,
    serverConfig,
  );

  // https://github.com/webpack/webpack-dev-middleware
  server.use(
    webpackDevMiddleware(clientCompiler, {
      publicPath: clientConfig.output.publicPath,
      logLevel: 'silent',
      watchOptions,
    }),
  );

  // https://github.com/glenjamin/webpack-hot-middleware
  server.use(webpackHotMiddleware(clientCompiler, { log: false }));

  let appPromise;
  let appPromiseResolve;
  let appPromiseIsResolved = true;
  serverCompiler.hooks.compile.tap('server', () => {
    if (!appPromiseIsResolved) return;
    appPromiseIsResolved = false;
    // eslint-disable-next-line no-return-assign
    appPromise = new Promise(resolve => (appPromiseResolve = resolve));
  });

  let app;
  server.use((req, res) => {
    appPromise
      .then(() => app.handle(req, res))
      .catch(error => console.error(error));
  });

  function checkForUpdate(fromUpdate) {
    const hmrPrefix = '[\x1b[35mHMR\x1b[0m] ';
    if (!app.hot) {
      throw new Error(`${hmrPrefix}Hot Module Replacement is disabled.`);
    }
    if (app.hot.status() !== 'idle') {
      return Promise.resolve();
    }
    return app.hot
      .check(true)
      .then(updatedModules => {
        if (!updatedModules) {
          if (fromUpdate) {
            console.info(`${hmrPrefix}Update applied.`);
          }
          return;
        }
        if (updatedModules.length === 0) {
          console.info(`${hmrPrefix}Nothing hot updated.`);
        } else {
          console.info(`${hmrPrefix}Updated modules:`);
          updatedModules.forEach(moduleId =>
            console.info(`${hmrPrefix} - ${moduleId}`),
          );
          checkForUpdate(true);
        }
      })
      .catch(error => {
        if (['abort', 'fail'].includes(app.hot.status())) {
          console.warn(`${hmrPrefix}Cannot apply update.`);
          delete require.cache[require.resolve('../build/server')];
          // eslint-disable-next-line global-require, import/no-unresolved
          app = require('../build/server').default;
          console.warn(`${hmrPrefix}App has been reloaded.`);
        } else {
          console.warn(
            `${hmrPrefix}Update failed: ${error.stack || error.message}`,
          );
        }
      });
  }

  serverCompiler.watch(watchOptions, (error, stats) => {
    if (app && !error && !stats.hasErrors()) {
      checkForUpdate().then(() => {
        appPromiseIsResolved = true;
        appPromiseResolve();
      });
    }
  });

  // Wait until both client-side and server-side bundles are ready
  await clientPromise;
  await serverPromise;

  const timeStart = new Date();
  console.info(`[${format(timeStart)}] Launching server...`);

  // Load compiled src/server.js as a middleware
  // eslint-disable-next-line global-require, import/no-unresolved
  app = require('../build/server').default;
  appPromiseIsResolved = true;
  appPromiseResolve();

  // Launch the development server with Browsersync and HMR
  await new Promise((resolve, reject) =>
    browserSync.create().init(
      {
        // https://www.browsersync.io/docs/options
        server: 'src/server.js',
        middleware: [server],
        open: !process.argv.includes('--silent'),
        ...(isDebug ? {} : { notify: false, ui: false }),
      },
      (error, bs) => (error ? reject(error) : resolve(bs)),
    ),
  );

  const timeEnd = new Date();
  const time = timeEnd.getTime() - timeStart.getTime();
  console.info(`[${format(timeEnd)}] Server launched after ${time} ms`);
  return server;
}
768035
function buildServerCmd(config) {
    var deferred = Q.defer()
      , app

    try {
        assertConfig(config)
        app = createMiddleware(config)
        createServer(config, app).then(onServerCreated, deferred.reject)
    } catch(error) {
        deferred.reject(error)
    }

    return deferred.promise

    function onServerCreated(server) {
        deferred.resolve(new Server(config, server, app))
    }
}
966155
function(config, environment) {
  //load configuration
  if (config == null)
    config = process.cwd() + (windows ? '\\' : '/');
    
  if (typeof config == 'string') {
    var isDir = (!windows && config.substr(config.length - 1, 1) == '/') || (windows && config.substr(config.length - 1, 1) == '\\');
    //config file path is taken to be app directory
    defaultConfig.appDir = isDir ? path.resolve(config) : path.dirname(path.resolve(config));
    defaultConfig.require.server.paths['$'] = defaultConfig.appDir;
    
    //load cson if necessary
    if (isDir && fs.existsSync(path.resolve(config, 'zest.cson')) || config.substr(config.length - 4, 4) == 'cson')
      return loadConfig(getCSONConfigFile(isDir ? path.resolve(config, 'zest.cson') : path.resolve(config)), environment);
    //otherwise load config as a json file
    else
      return loadConfig(getJSONConfigFile(isDir ? path.resolve(config, 'zest.json') : path.resolve(config)), environment);
  }
  
  if (setConfig)
    throw 'Configuration has already been set. Start a new server instance for alternative configuration.';
  setConfig = true;
  
  
  function deepPrepend(a, b) {
    for (var p in b) {
      if (b[p] instanceof Array) {
        a[p] = a[p] || [];
        a[p] = b[p].concat(a[p]);
      }
      else if (typeof b[p] == 'object' && b[p] !== null && a[p] !== null) {
        a[p] = a[p] || {};
        deepPrepend(a[p], b[p]);
      }
      else if (a[p] === undefined)
        a[p] = b[p];
    }
  }
  
  deepPrepend(config, defaultConfig);
  
  //provide default configurations, starting with the environment mode config
  var outConfig = config.environments[environment || config.environment];
  
  if (typeof outConfig == 'undefined')
    throw 'No configuration provided for environment "' + environment + '".';
  
  delete config.environments;
  
  deepPrepend(outConfig, config);
  
  //derive client, build, server and production require configs
  var requireConfig = {
    server: outConfig.require.server,
    client: outConfig.require.client,
    build: outConfig.require.build
  };
  delete outConfig.require.server;
  delete outConfig.require.client;
  delete outConfig.require.build;
  
  deepPrepend(requireConfig.server, outConfig.require);
  deepPrepend(requireConfig.client, outConfig.require);
  deepPrepend(requireConfig.build, outConfig.require);
  
  outConfig.require = requireConfig;
  
  //set directories - cant override
  outConfig.require.server.baseUrl = path.resolve(outConfig.appDir, outConfig.publicDir, outConfig.baseDir);
  outConfig.require.client.baseUrl = '/' + outConfig.baseDir;

  // type attribute
  if (outConfig.typeAttribute && outConfig.typeAttribute != 'component') {
    var clientConfig = (outConfig.require.client.config = outConfig.require.client.config || {});
    clientConfig['zest/render'] = clientConfig['zest/render'] || {};
    clientConfig['zest/render'].typeAttribute = outConfig.typeAttribute;
  }
  
  return outConfig;
}
225933
public static TemplateEngine create(TemplateConfig config) {
		final TemplateEngine engine = doCreate(config);
		StaticLog.debug("Use [{}] Engine As Default.", StrUtil.removeSuffix(engine.getClass().getSimpleName(), "Engine"));
		return engine;
	}
150028
function initDir (config) {
    // create global dir config
    config.dir = {
        assets: [__dirname+'/assets'],
        app: [],
        components: [],
        helpers: [__dirname+'/helpers'],
        layouts: [__dirname+'/layouts'],
        partials: [__dirname+'/partials'],
        services: [],
        views: [__dirname+'/views'],
    }
    // iterate over modules getting and merging directories for each
    _.each(config.moduleNames, moduleName => {
        // get module
        var module = config.modules[moduleName]
        // iterate over dir configs
        _.each(config.dir, (dirs, dirName) => {
            // get directories for module
            var moduleDirs = getDir(module, dirName)
            // debug
            debug('initDir %s %s', moduleName, dirName, moduleDirs)
            // add module dirs to config
            _.each(moduleDirs, moduleDir => config.dir[dirName].push(moduleDir))
        })
    })
    // debug merged dirs
    debug('initDir', config.dir)
}
1090279
function (config) {
    /**
     * The iterator function, which is called on each component.
     *
     * @param  {string} version    the version of the component
     * @param  {string} component  the name of the component
     * @return {undefined}
     */
    return function (version, component) {
        var dep = config.get('global-dependencies').get(component) || {
            main: '',
            type: '',
            name: '',
            dependencies: {}
        };

        console.log(version, component);

        var componentConfigFile = findComponentConfigFile(config, component);
        var warnings = config.get('warnings');

        var overrides = config.get('overrides');

        if (overrides && overrides[component]) {
            if (overrides[component].dependencies) {
                componentConfigFile.dependencies = overrides[component].dependencies;
            }

            if (overrides[component].main) {
                componentConfigFile.main = overrides[component].main;
            }
        }

        var mains = findMainFiles(config, component, componentConfigFile);
        var fileTypes = _.chain(mains).map(path.extname).unique().value();

        dep.main = mains;
        dep.type = fileTypes;
        dep.name = componentConfigFile.name;

        var depIsExcluded = _.find(config.get('exclude'), function (pattern) {
            return path.join(config.get('bower-directory'), component).match(pattern);
        });

        if (dep.main.length === 0 && !depIsExcluded) {
            // can't find the main file. this config file is useless!
            warnings.push(component + ' was not injected in your file.');
            warnings.push(
                'Please go take a look in "' + path.join(config.get('bower-directory'), component) + '" for the file you need, then manually include it in your file.');

            config.set('warnings', warnings);
            return;
        }

        if (componentConfigFile.dependencies) {
            dep.dependencies = componentConfigFile.dependencies;

            _.each(componentConfigFile.dependencies, gatherInfo(config));
        }

        config.get('global-dependencies').set(component, dep);
    };
}
499489
function setup (config = {}) {
  config = merge({}, defaults.axios, config)

  const cache = setupCache(config.cache)
  const axiosConfig = omit(config, ['cache'])

  const api = axios.create(
    merge({}, axiosConfig, { adapter: cache.adapter })
  )

  api.cache = cache.store

  return api
}
369444
function _use(config) {
    var _config = this._config;

    Object.keys(config).forEach(function(key) {
      _config[key] = config[key];
    });

    return this;
  }