Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
// Authenticate using our plain-object database of doom!

function authenticate(name, pass, fn) {
if (!module.parent) console.log('authenticating %s:%s', name, pass);
if (require.main === module) console.log('authenticating %s:%s', name, pass);

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
an access to password
as clear text.
var user = users[name];
// query the db for the given username
if (!user) return fn(null, null)
Expand Down Expand Up @@ -128,7 +128,7 @@
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/content-negotiation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function format(path) {
app.get('/users', format('./users'));

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/cookie-sessions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ app.get('/', function (req, res) {
})

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/cookies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ app.post('/', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.get('/files/*file', function (req, res, next) {
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/ejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ app.get('/', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/error-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ app.use(function(err, req, res, next){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/error/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ app.get('/next', function(req, res, next){
app.use(error);

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/hello-world/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app.get('/', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ app.get('/fail', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/multi-router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ app.get('/', function(req, res) {
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
8 changes: 4 additions & 4 deletions examples/mvc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ app.response.message = function(msg){
};

// log
if (!module.parent) app.use(logger('dev'));
if (require.main === module) app.use(logger('dev'));

// serve static files
app.use(express.static(path.join(__dirname, 'public')));
Expand Down Expand Up @@ -73,11 +73,11 @@ app.use(function(req, res, next){
});

// load controllers
require('./lib/boot')(app, { verbose: !module.parent });
require('./lib/boot')(app, { verbose: require.main === module });

app.use(function(err, req, res, next){
// log it
if (!module.parent) console.error(err.stack);
if (require.main === module) console.error(err.stack);

// error page
res.status(500).render('5xx');
Expand All @@ -89,7 +89,7 @@ app.use(function(req, res, next){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/online/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ app.get('/', function(req, res, next){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/params/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ app.get('/users/:from-:to', function (req, res) {
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/resource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ app.get('/', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/route-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ app.map({
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/route-middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ app.delete('/user/:id', loadUser, andRestrictTo('admin'), function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
4 changes: 2 additions & 2 deletions examples/route-separation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.use(logger('dev'));
}

Expand All @@ -49,7 +49,7 @@ app.put('/user/:id/edit', user.update);
app.get('/posts', post.list);

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ app.get('/client.js', function(req, res){

(async () => {
await initializeRedis();
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
Expand Down
2 changes: 1 addition & 1 deletion examples/session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ app.get('/', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
6 changes: 3 additions & 3 deletions examples/vhost/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ edit /etc/hosts:

var main = express();

if (!module.parent) main.use(logger('dev'));
if (require.main === module) main.use(logger('dev'));

main.get('/', function(req, res){
res.send('Hello from main app!');
Expand All @@ -35,7 +35,7 @@ main.get('/:sub', function(req, res){
var redirect = express();

redirect.use(function(req, res){
if (!module.parent) console.log(req.vhost);
if (require.main === module) console.log(req.vhost);
res.redirect('http://example.com:3000/' + req.vhost[0]);
});

Expand All @@ -47,7 +47,7 @@ app.use(vhost('*.example.com', redirect)); // Serves all subdomains via Redirect
app.use(vhost('example.com', main)); // Serves top level domain via Main server app

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/view-constructor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.get('/Readme.md', function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/view-locals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ app.all('/api/*', function(req, res, next){
*/

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}
2 changes: 1 addition & 1 deletion examples/web-service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ app.use(function(req, res){
});

/* istanbul ignore next */
if (!module.parent) {
if (require.main === module) {
app.listen(3000);
console.log('Express started on port 3000');
}