Skip to content

Application may be a class #2562

Open
Open
@ibc

Description

@ibc

https://github.com/strongloop/express/blob/5.0/lib/application.js

The fact is that lib/application.js may perfectly export the constructor of a "real" Application class, and define its prototype as usual instead of var app = exports = module.exports = {};. I mean:

module.exports = Application;


function Application() {
  var router = null;

  this.cache = {};
  this.settings = {};
  this.engines = {};
  this.defaultConfiguration();

  etc etc
}

Application.prototype.defaultConfiguration = function() {
  ...
};

Application.prototype.handle = function(req, res, done) {
  ...
};

I don't see any downside in doing it that way, do I miss something? At the end the new Router class is now designed as a "real" JavaScript class.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions