Installing plugins
Plugins
Plugins are a way of extending the functionality of Mocks Server.
Some things that can be made with a plugin are:
- Load
mocks
orroutes
. - Listen to Mocks Server events and act in consequence.
- Add custom express routers to the server.
- Add new options, accessible to the users even through command line arguments, environment variables, or any other configuration method.
- Change configuration while the server is running.
- Add new formats of defining
route variants
. (Using custom routes handlers)
How to install plugins
Configuration file
Use the configuration file for installing plugins.
const FooPlugin = require("mocks-server-plugin-foo");
module.exports = {
...config,
plugins: {
register: [FooPlugin],
}
};
Programmatically
If you are using the @mocks-server/core package to start Mocks Server programmatically, you can define the plugins to use as described in the programmatic usage chapter.
Searching plugins
Use the "mocks-server-plugin" tag to search Mocks Server plugins in NPM.