Configuration

Mockly can be configured through the .mocklyrc file, where you can put your configuration in JSON format. These options are available:

Option

Type

Default

Description

delay

number

0

Applies a delay to all requests made to the server

port

number

3000

Defines in which port the server will be mounted

prefix

string

Applies a prefix to all endpoints available

resourceFilesGlob

string

**/*.resource.json

Changes the glob used to find resource files configurations

rewritesFilesGlob

string

**/*.rewrites.json

Changes the glob used to find rewrites files configurations

responsesConfigGlob

string

**/*.responses.json

Changes the glob used to find responses files configurations

To configure the tool, create a .mocklyrc file in the root of your project directory with your JSON configuration object, you can use the provided JSON Schema to validate your data.

.mocklyrc
{
    "$schema": "node_modules/@mockly/core/tools/schemas/configuration.json",
    "delay": 500,
    "port": 3001,
    "prefix": "/api/v1",
    "resourceFilesGlob": "**/*.db.json",
    "rewritesFilesGlob": "**/*.redirects.json",
    "responsesConfigGlob": "**/*.rconfigs.json"
}

Last updated