Github user omefire commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/314#discussion_r41426471
  
    --- Diff: cordova-serve/serve.js ---
    @@ -17,9 +17,41 @@
      under the License.
      */
     
    -module.exports = {
    -    sendStream: require('./src/stream'),
    -    servePlatform: require('./src/platform'),
    -    launchServer: require('./src/server'),
    -    launchBrowser: require('./src/browser')
    +var chalk = require('chalk'),
    +    compression = require('compression'),
    +    express = require('express'),
    +    server = require('./src/server');
    +
    +module.exports = function () {
    +    return new CordovaServe();
     };
    +
    +function CordovaServe() {
    +    this.app = express();
    +
    +    // Attach this before anything else to provide status output
    +    this.app.use(function (req, res, next) {
    +        res.on('finish', function () {
    +            var color = this.statusCode == '404' ? chalk.red : chalk.green;
    +            var msg = color(this.statusCode) + ' ' + this.req.originalUrl;
    +            var encoding = this._headers && 
this._headers['content-encoding'];
    +            if (encoding) {
    +                msg += chalk.gray(' (' + encoding + ')');
    +            }
    +            server.log(msg);
    +        });
    +        next();
    +    });
    +
    +    // Turn on compression
    +    this.app.use(compression());
    +
    +    this.servePlatform = require('./src/platform');
    +    this.launchServer = server;
    +}
    --- End diff --
    
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to