mirror of
https://gitlab.silvrtree.co.uk/martind2000/frontexpress.git
synced 2025-01-25 18:26:16 +00:00
Update README.md
This commit is contained in:
parent
2245de31d7
commit
d678d066c3
51
README.md
51
README.md
@ -213,6 +213,57 @@ import birds from './birds';
|
||||
app.use('/birds', birds);
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
### Extend frontexpress via plugins:
|
||||
|
||||
- [frontexpress-path-to-regexp](https://github.com/camelaissani/frontexpress-path-to-regexp): Add the ability to support Express-style path string such as /user/:name, /user*...
|
||||
|
||||
Others are coming
|
||||
|
||||
### Write your own plugin
|
||||
|
||||
It consists to simply create an object with two properties:
|
||||
- **name**: the name of your plugin
|
||||
- **plugin**: the function containing the implementation
|
||||
|
||||
Let's assume that we have implemented this plugin in the `frontexpress-my-plugin.js` file as below:
|
||||
|
||||
```js
|
||||
export default {
|
||||
name: 'My plugin',
|
||||
plugin(app) {
|
||||
// the plugin implementation goes here
|
||||
|
||||
// Same ideas
|
||||
// you can get settings
|
||||
// const transformer = app.get('http GET transformer');
|
||||
//
|
||||
// you can set settings
|
||||
// app.set('http requester', {
|
||||
// fetch() {
|
||||
// ...
|
||||
// }});
|
||||
//
|
||||
// you can complete routes
|
||||
// app.get(...)
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
To use it:
|
||||
|
||||
```js
|
||||
import frontexpress from 'frontexpress';
|
||||
import myPlugin from 'frontexpress-my-plugin';
|
||||
|
||||
// Front-end application
|
||||
const app = frontexpress();
|
||||
|
||||
// tell to frontexpress to use your plugin
|
||||
app.use(myPlugin);
|
||||
```
|
||||
|
||||
## More
|
||||
|
||||
[API](https://github.com/camelaissani/frontexpress/blob/master/docs/api.md)
|
||||
|
Loading…
Reference in New Issue
Block a user