mirror of
https://gitlab.silvrtree.co.uk/martind2000/frontexpress.git
synced 2025-02-10 19:29:15 +00:00
added docs
This commit is contained in:
parent
2bcf695198
commit
be20f98498
77
docs/application.md
Normal file
77
docs/application.md
Normal file
@ -0,0 +1,77 @@
|
||||
# Application
|
||||
|
||||
## Application.set(setting, val)
|
||||
|
||||
Assign `setting` to `val`, or return `setting`'s value.
|
||||
|
||||
```js
|
||||
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'.
|
||||
|
||||
```js
|
||||
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.
|
||||
|
||||
```js
|
||||
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 "/".
|
||||
|
||||
```js
|
||||
// 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
|
22
docs/frontexpress.md
Normal file
22
docs/frontexpress.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Frontexpress
|
||||
|
||||
|
||||
## frontexpress()
|
||||
|
||||
Create a frontexpress application.
|
||||
|
||||
**Returns**: `Application`, the application
|
||||
|
||||
|
||||
## frontexpress.Router
|
||||
|
||||
Expose the Router constructor
|
||||
|
||||
**Returns**: `Router`
|
||||
|
||||
|
||||
## frontexpress.Middleware()
|
||||
|
||||
Expose the Middleware constructor
|
||||
|
||||
**Returns**: `Middleware`
|
63
docs/middleware.md
Normal file
63
docs/middleware.md
Normal file
@ -0,0 +1,63 @@
|
||||
# Middleware
|
||||
|
||||
## Middleware.entered(request)
|
||||
|
||||
Invoked by the app before ajax request are sent or
|
||||
during the DOM loading (document.readyState === 'loading').
|
||||
See Application#_callMiddlewareEntered documentation for details.
|
||||
|
||||
Override this method to add your custom behaviour
|
||||
|
||||
**Parameters**
|
||||
|
||||
**request**: `Object`
|
||||
|
||||
|
||||
## Middleware.exited(request)
|
||||
|
||||
Invoked by the app before a new ajax request is sent or before the DOM unloading.
|
||||
See Application#_callMiddlewareExited documentation for details.
|
||||
|
||||
Override this method to add your custom behaviour
|
||||
|
||||
**Parameters**
|
||||
|
||||
**request**: `Object`
|
||||
|
||||
|
||||
## Middleware.updated(request, response)
|
||||
|
||||
Invoked on ajax request responding or on DOM ready
|
||||
(document.readyState === 'interactive').
|
||||
See Application#_callMiddlewareUpdated documentation for details.
|
||||
|
||||
Override this method to add your custom behaviour
|
||||
|
||||
**Parameters**
|
||||
|
||||
**request**: `Object`
|
||||
|
||||
**response**: `Object`
|
||||
|
||||
|
||||
## Middleware.failed(request, response)
|
||||
|
||||
Invoked when ajax request fails.
|
||||
|
||||
Override this method to add your custom behaviour
|
||||
|
||||
**Parameters**
|
||||
|
||||
**request**: `Object`
|
||||
|
||||
**response**: `Object`
|
||||
|
||||
|
||||
## Middleware.next()
|
||||
|
||||
Allow the hand over to the next middleware object or function.
|
||||
|
||||
Override this method and return `false` to break execution of
|
||||
middleware chain.
|
||||
|
||||
**Returns**: `Boolean`, `true` by default
|
39
docs/router.md
Normal file
39
docs/router.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Router
|
||||
|
||||
## Router.use(middleware)
|
||||
|
||||
Use the given middleware function or object on this router.
|
||||
|
||||
```js
|
||||
// middleware function
|
||||
router.use((req, res, next) => {console.log('Hello')});
|
||||
|
||||
// middleware object
|
||||
router.use(new Middleware());
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
**middleware**: `Middleware | function`, Middleware object or function
|
||||
|
||||
**Returns**: `Router`, for chaining
|
||||
|
||||
|
||||
## Router.all(middleware)
|
||||
|
||||
Use the given middleware function or object on this router for
|
||||
all HTTP methods.
|
||||
|
||||
```js
|
||||
// middleware function
|
||||
router.all((req, res, next) => {console.log('Hello')});
|
||||
|
||||
// middleware object
|
||||
router.all(new Middleware());
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
**middleware**: `Middleware | function`, Middleware object or function
|
||||
|
||||
**Returns**: `Router`, for chaining
|
Loading…
Reference in New Issue
Block a user