Skip to main content
Version: 2.3.0

Programmatic usage

Core usage

The server can be instantiated and started programmatically using the @mocks-server/core package, which does not include plugins.

You can also register your own or another existing plugins, so you could even create your custom distribution with plugins of your choice.

Example

const { Core } = require("@mocks-server/core");
const AdminApi = require("@mocks-server/plugin-admin-api");
const InquirerCli = require("@mocks-server/plugin-inquirer-cli");

const mocksServer = new Core({
onlyProgrammaticOptions: false,
plugins: [AdminApi, InquirerCli]
});

mocksServer
.init({
port: 3500,
delay: 1000,
log: "debug"
})
.then(server.start);

Core API

new Core([config])

Arguments

Core instance API

Please read the mocksServer API chapter to know all available methods and getters in the mocksServer instance that the Core class returns.