Init
Create a mock-config-server template from the command line
Creates a mock configuration. It generates a mock-server.config.(js|ts) file in the current directory. An interactive flow lets you choose between TypeScript and JavaScript, select an API preset, and set basic server options like base URL, port, and static path.
Usage
npx mock-config-server initIf the package is already installed, you can use the short command
mcs
Options
| Option | Short | Description | Default value |
|---|---|---|---|
--baseUrl | -b | Specify the base URL. Must start with /. | / |
--port | -p | Specify the server port. | 7777 |
--staticPath | -s | Specify the static assets path. Must start with /. |
Interactive flow
The command asks a few short questions:
? Would you like to use TypeScript? › Yes / No
? Choose API type (Use arrow keys)
❯ REST
REST playground
GraphQL
GraphQL playground
WebSocket
Full API
? Base URL (must start with a forward slash): › /
? Port: › (7777)
? Static path (must start with a forward slash): › /Would you like to use TypeScript?(toggle): choose whether to generate a TypeScript or JavaScript configuration file.Choose API type(select): select the API preset for the generated config. Options:REST,REST playground,GraphQL,GraphQL playground,WebSocket, orFull API.Base URL(string): set the base URL path for the mock server. Must start with/. Default:/.Port(number): set the port number for the mock server. Default:7777.Static path(string): set the static assets path for the mock server. Must start with/. Default:/.
Presets
| Preset | Description |
|---|---|
REST | Basic REST users example with list and item routes. |
REST playground | REST users example with CRUD routes. |
GraphQL | Basic GraphQL users example with list and item queries. |
GraphQL playground | GraphQL users example with CRUD operations. |
WebSocket | WebSocket connection and message example. |
Full API | REST, GraphQL, and WebSocket examples in one config. |