examples/basic/server.js
function defineApp(app) {

    app.use('/foo', function appFoo(req, res) {
        if (req.xhr) {
            var body = {
                foo: 'bar'
            };
            responseSender.sendJSON(res, body);
        } else {
            responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200);
        }
    });

    app.use('/fail', function appFail(req, res) {
        /* jshint unused: false, quotmark: false */
        throw new Error("Don't worry, the error handler will take care of this");
    });

    app.use('/fail-async', function appFailAsync(req, res) {
        /* jshint unused: false, quotmark: false */
        setTimeout(function() {
            throw new Error("I may be async, but the error handler will still catch me!");
        }, 100);
    });


    app.use('/', express.static(__dirname));

}
function defineApp(app) {

    app.use('/foo', function appFoo(req, res) {
        if (req.xhr) {
            var body = {
                foo: 'bar'
            };
            responseSender.sendJSON(res, body);
        } else {
            responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200);
        }
    });

    app.use('/fail', function appFail(req, res) {
        /* jshint unused: false, quotmark: false */
        throw new Error("Don't worry, the error handler will take care of this");
    });

    app.use('/fail-async', function appFailAsync(req, res) {
        /* jshint unused: false, quotmark: false */
        setTimeout(function() {
            throw new Error("I may be async, but the error handler will still catch me!");
        }, 100);
    });


    app.use('/', express.static(__dirname));

}
function defineApp ( app ) { app . use ( '/foo' , function appFoo ( req , res ) { if ( req . xhr ) { var body = { foo : 'bar' } ; responseSender . sendJSON ( res , body ) ; } else { responseSender . sendPage ( res , 'Foo' , '<h1>Bar!</h1>' , 200 ) ; } } ) ; app . use ( '/fail' , function appFail ( req , res ) { /* jshint unused: false, quotmark: false */ throw new Error ( "Don't worry, the error handler will take care of this" ) ; } ) ; app . use ( '/fail-async' , function appFailAsync ( req , res ) { /* jshint unused: false, quotmark: false */ setTimeout ( function ( ) { throw new Error ( "I may be async, but the error handler will still catch me!" ) ; } , 100 ) ; } ) ; app . use ( '/' , express . static ( __dirname ) ) ; }
Defines the express application that your server will run
a.k.a. the routes, logic, etc. of your web application.
Simply setup the application exactly as you would when using express directly.
@param an express application, which this function will manipulate and augment
Defines the express application that your server will run a . k . a . the routes logic etc . of your web application . Simply setup the application exactly as you would when using express directly .