It looks like implementing basic HTTP authentication with Express v3 was trivial:
app.use(express.basicAuth(\'username\', \'password\'));
V
A lot of the middleware was pulled out of the Express core in v4, and put into separate modules. The basic auth module is here: https://github.com/expressjs/basic-auth-connect
Your example would just need to change to this:
var basicAuth = require('basic-auth-connect');
app.use(basicAuth('username', 'password'));