frontexpress/docs/application.md
Camel Aissani be20f98498 added docs
2016-07-23 00:02:34 +02:00

1.4 KiB

Application

Application.set(setting, val)

Assign setting to val, or return setting's value.

   app.set('foo', 'bar');
   app.set('foo');
   // => "bar"

Parameters

setting: String, setting name

val: *, setting value

Returns: app, for chaining

Application.listen(callback)

Listen to DOM initialization and history state changes.

The callback function is called once the DOM has the document.readyState equals to 'interactive'.

   app.listen(()=> {
       console.log('App is listening requests');
       console.log('DOM is ready!');
   });

Parameters

callback: function, DOM is ready callback

Application.route(uri)

Returns a new Router instance for the uri. See the Router api docs for details.

   app.route('/');
   // =>  new Router instance

Parameters

uri: String, path

Returns: Router, for chaining

Application.use(uri, middleware)

Use the given middleware function or object, with optional uri. Default uri is "/".

   // middleware function will be applied on path "/"
   app.use((req, res, next) => {console.log('Hello')});

   // middleware object will be applied on path "/"
   app.use(new Middleware());

Parameters

uri: String, path

middleware: Middleware | function, Middleware object or function

Returns: app, for chaining