DragonKnight
DragonKnight

Reputation: 1870

what does this line of code in express.js mean?

Can someone explain in depth what does this line of code mean in NodeJS:

var app = module.exports = express.createServer();

Upvotes: 0

Views: 164

Answers (2)

gnuns
gnuns

Reputation: 626

It can be rewritten as:

module.exports = express.createServer();
var app = module.exports;

Upvotes: 1

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

express.createServer();

The above line has the instance of express and creates a server instance (server handle) and returns the whole export class.

With the above, you are setting both module.exports as well as app to do further.

Upvotes: 4

Related Questions