You can use:
server.js
var Server = function() {
this.someVar = 1;
};
Server.prototype.someMethod1 = function() {
console.log("1");
};
Server.prototype.someMethod2 = function() {
console.log("2");
};
module.exports.createServer = function () {
return new Server();
};
And to use it:
var server = require("./app/server").createServer();
If you want to be able to create instances of your server in "express fashion" you can use:
module.exports = function () {
return new Server();
};
And to use that:
var server = require("./app/server")();