AK-21/Graphite-Industrial-Intelligence
0
1/*!2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2013 Roman Shtylman5 * Copyright(c) 2014-2015 Douglas Christopher Wilson6 * MIT Licensed7 */8 9'use strict';10 11/**12 * Module dependencies.13 */14 15var bodyParser = require('body-parser')16var EventEmitter = require('node:events').EventEmitter;17var mixin = require('merge-descriptors');18var proto = require('./application');19var Router = require('router');20var req = require('./request');21var res = require('./response');22 23/**24 * Expose `createApplication()`.25 */26 27exports = module.exports = createApplication;28 29/**30 * Create an express application.31 *32 * @return {Function}33 * @api public34 */35 36function createApplication() {37 var app = function(req, res, next) {38 app.handle(req, res, next);39 };40 41 mixin(app, EventEmitter.prototype, false);42 mixin(app, proto, false);43 44 // expose the prototype that will get set on requests45 app.request = Object.create(req, {46 app: { configurable: true, enumerable: true, writable: true, value: app }47 })48 49 // expose the prototype that will get set on responses50 app.response = Object.create(res, {51 app: { configurable: true, enumerable: true, writable: true, value: app }52 })53 54 app.init();55 return app;56}57 58/**59 * Expose the prototypes.60 */61 62exports.application = proto;63exports.request = req;64exports.response = res;65 66/**67 * Expose constructors.68 */69 70exports.Route = Router.Route;71exports.Router = Router;72 73/**74 * Expose middleware75 */76 77exports.json = bodyParser.json78exports.raw = bodyParser.raw79exports.static = require('serve-static');80exports.text = bodyParser.text81exports.urlencoded = bodyParser.urlencoded82 