diff --git a/README.md b/README.md index fe5187c..e6a2eb0 100644 --- a/README.md +++ b/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)