Plugins installation
NPM installation
In order to install a plugin, first you have to install the correspondent NPM dependency:
npm i --save-dev mocks-server-plugin-foo
Configuration file
Once installed, you have to register it in the Mocks Server configuration. You can do it using the configuration file:
const FooPlugin = require("mocks-server-plugin-foo");
module.exports = {
...config,
plugins: {
register: [FooPlugin],
}
};
Using JavaScript
If you are going to start Mocks Server using the Javascript API, you can also use the programmatic configuration to register your own plugins:
const Core = require("@mocks-server/core");
const MyPlugin = require("./MyPlugin");
const server = new Core(
{
plugins: {
register: [MyPlugin],
},
},
);
server.start();