Sha256: e9959b7b87b75ba341c5b677287626b7ddae3056ca87a8a7e58c8f101b16a9fb

Contents?: true

Size: 1.8 KB

Versions: 17

Compression:

Stored size: 1.8 KB

Contents

/*!
 * Connect
 * Copyright(c) 2010 Sencha Inc.
 * Copyright(c) 2011 TJ Holowaychuk
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var deprecate = require('depd')('connect');
var EventEmitter = require('events').EventEmitter
  , proto = require('./proto')
  , utils = require('./utils')
  , path = require('path')
  , basename = path.basename
  , fs = require('fs');

// node patches

require('./patch');

// expose createServer() as the module

exports = module.exports = createServer;

/**
 * Framework version.
 */

exports.version = require('../package').version;

/**
 * Expose mime module.
 */

exports.mime = require('./middleware/static').mime;

/**
 * Expose the prototype.
 */

exports.proto = proto;

/**
 * Auto-load middleware getters.
 */

exports.middleware = {};

/**
 * Expose utilities.
 */

exports.utils = utils;

/**
 * Create a new connect server.
 *
 * @return {Function}
 * @api public
 */

function createServer() {
  function app(req, res, next){ app.handle(req, res, next); }
  utils.merge(app, proto);
  utils.merge(app, EventEmitter.prototype);
  app.route = '/';
  app.stack = [];

  if (arguments.length !== 0) {
    deprecate('connect(middleware): use app.use(middleware) instead');
  }

  for (var i = 0; i < arguments.length; ++i) {
    app.use(arguments[i]);
  }

  return app;
};

/**
 * Support old `.createServer()` method.
 */

createServer.createServer = deprecate.function(createServer,
  'createServer(): use connect() instead');

/**
 * Auto-load bundled middleware with getters.
 */

fs.readdirSync(__dirname + '/middleware').forEach(function(filename){
  if (!/\.js$/.test(filename)) return;
  var name = basename(filename, '.js');
  function load(){ return require('./middleware/' + name); }
  exports.middleware.__defineGetter__(name, load);
  exports.__defineGetter__(name, load);
});

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/lib/connect.js