Options
Options
Here are described the Mocks Server core options. To know how to define them using different methods, please read the previous chapter.
config.allowUnknownArguments
(Boolean): Iftrue
, it allows to define unknown command line arguments. Default isfalse
. This option can be defined only programmatically, using configuration file or environment variables.config.fileSearchPlaces
(Array of Strings): Paths to search for the configuration file. Default is described in the configuration methods chapter. This option can be defined only programmatically or using environment variables.config.readArguments
(Boolean): Iffalse
, it disables the ability of defining options using command line arguments. Default istrue
. This option can be defined only programmatically, using configuration file or environment variables.config.readEnvironment
(Boolean): Iffalse
, it disables the ability of defining options using environment variables. Default istrue
. This option can be defined only programmatically.config.readFile
(Boolean): Iffalse
, it disables the ability of reading configuration file. Default istrue
. This option can be defined only programmatically, using configuration file or environment variables.files.path
(String): Path to the folder containing mocks and routes to be used by the server. Default is/mocks
files.watch
(Boolean): Watch mocks folder and restart server on changes. Default istrue
.files.babelRegister.enabled
(Boolean): Enables Babel compilation for files inside the mocks folder.files.babelRegister.options
(Object): Options for@babel/register
whenbabelRegister
is enabled. Properties in this object are passed directly to@babel/register
as options, so refer to its documentation for further info. You can also see some usage examples in the "using Babel" section of this docs.log
(String): Logs level. Can be one ofsilly
,debug
,verbose
,info
,warn
orerror
.mocks.delay
(Number): Responses delay time in milliseconds. This is a global setting that can be overridden for specific routes or route variants using their options.mocks.selected
(String): Mock to use when the server is started.plugins.register
: (Array ofPlugin
): Array of Plugins, defined as described in the plugins chapter.routesHandlers
(Array ofRouteHandler
): Array ofRouteHandler
to be added.server.cors.enabled
(Boolean): Built-in CORS middleware. Default istrue
. Usefalse
to disable it.server.cors.options
(Object): Options for the built-in CORS middleware. By default, it sets thepreflightContinue
property asfalse
, which means that Mocks Server will respond to allOPTIONS
requests with a 204 status and correspondent CORS headers. If you want to handle OPTIONS requests by yourself, you should set that property totrue
.server.host
(String): Host for the server. Default is0.0.0.0
(Listen to any local host).server.jsonBodyParser.enabled
(Boolean): Iffalse
, it disables thejson
body-parser
built-in Express middleware. Default istrue
.server.jsonBodyParser.options
(Object): Options for thejson
body-parser
built-in Express middleware.server.port
(Number): Port number for Mocks Server to be listening at. Default is3100
.server.urlEncodedBodyParser.enabled
(Boolean): Iffalse
, it disables theurlencoded
body-parser
built-in Express middleware. Default istrue
.server.urlEncodedBodyParser.options
(Object): Options for theurlencoded
body-parser
built-in Express middleware.
Plugins options
Each plugin can add its own options when it is installed. These options can also be defined and changed using the same methods as the core options. Note that all plugins options must be defined under the plugins
namespace, and each plugin options must be defined under its own plugin id namespace (plugins.[plugin-id].[option]
)
plugins.inquirerCli.enabled
(Boolean): Start interactive CLI plugin or not. Default istrue
.plugins.inquirerCli.emojis
(Boolean): Defines whether the inquirer CLI uses emojis or not. Default istrue
.plugins.adminApi.path
(String): Path for the administration REST API. Default is/admin
. You should change it only in case there is any conflict with the API you are mocking.
note
These extra options are added by the @mocks-server/plugin-admin-api and the @mocks-server/plugin-inquirer-cli plugins, which are both included in the Mocks Server main distribution.
For another plugins options, please refer to their own documentation.