You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
1.6 KiB

  1. /**
  2. * Module dependencies.
  3. */
  4. var connect = require('connect')
  5. , proto = require('./application')
  6. , Route = require('./router/route')
  7. , Router = require('./router')
  8. , req = require('./request')
  9. , res = require('./response')
  10. , utils = connect.utils;
  11. /**
  12. * Expose `createApplication()`.
  13. */
  14. exports = module.exports = createApplication;
  15. /**
  16. * Framework version.
  17. */
  18. exports.version = '3.2.5';
  19. /**
  20. * Expose mime.
  21. */
  22. exports.mime = connect.mime;
  23. /**
  24. * Create an express application.
  25. *
  26. * @return {Function}
  27. * @api public
  28. */
  29. function createApplication() {
  30. var app = connect();
  31. utils.merge(app, proto);
  32. app.request = { __proto__: req };
  33. app.response = { __proto__: res };
  34. app.init();
  35. return app;
  36. }
  37. /**
  38. * Expose connect.middleware as express.*
  39. * for example `express.logger` etc.
  40. */
  41. for (var key in connect.middleware) {
  42. Object.defineProperty(
  43. exports
  44. , key
  45. , Object.getOwnPropertyDescriptor(connect.middleware, key));
  46. }
  47. /**
  48. * Error on createServer().
  49. */
  50. exports.createServer = function(){
  51. console.warn('Warning: express.createServer() is deprecated, express');
  52. console.warn('applications no longer inherit from http.Server,');
  53. console.warn('please use:');
  54. console.warn('');
  55. console.warn(' var express = require("express");');
  56. console.warn(' var app = express();');
  57. console.warn('');
  58. return createApplication();
  59. };
  60. /**
  61. * Expose the prototypes.
  62. */
  63. exports.application = proto;
  64. exports.request = req;
  65. exports.response = res;
  66. /**
  67. * Expose constructors.
  68. */
  69. exports.Route = Route;
  70. exports.Router = Router;
  71. // Error handler title
  72. exports.errorHandler.title = 'Express';