
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
mock-config-server
Advanced tools
Tool that easily and quickly imitates server operation, create full fake api in few steps
tool that easily and quickly imitates server operation, create full fake api in few steps
$ npm i mock-config-server --save --dev
# or
$ yarn add mock-config-server --dev
🎉 Mock Config Server it is a tool that, easily, quickly simulates the work of a server. The main difference from solutions such as json-server and mock-service-worker is the ease of filling in data and flexible emulation of any and usual cases. Our goal is to create a simple and flexible system for users, with the help of which they can create, test, and support their products.
Install 🎉 Mock Config Server with npm or yarn
$ npm i mock-server --save --dev
# or
$ yarn add mock-server --dev
Create a mock-server.config.js
file with server configuration
/** @type {import('mock-server').Mock.ServerConfig} */
const mockServerConfig: Mock.ServerConfig = {
configs: [
{
path: '/user',
method: 'get',
routes: [{ data: { emoji: '🦁', name: 'Nursultan' } }]
}
]
};
module.exports = mockServerConfig;
Start 🎉 Mock Config Server
$ mock-config-server
# 🎉 Mock Config Server is running at http://localhost:31299
configs
{Array} configs for mock requests, readstaticPath?
{StaticPath} entity for working with static files, readinterceptors?
{Interceptors} functions to change request or response parameters, readcors?
{Cors} CORS settings object (default: CORS is turn off
), readport?
{number} server port (default: 31299
)baseUrl?
{string} part of the url that will be substituted at the beginning of the request url (default: '/'
)Configs are the fundamental part of the mock server. These configs are easy to fill and maintain. Config entities is an object with which you can emulate various application behaviors. You can specify headers
| query
| params
| body
to define what contract data you need to get. Using this mechanism, you can easily simulate the operation of the server and emulate various cases
path
{string | RegExp} request pathmethod
{GET | POST | DELETE | PUT | PATCH} rest api methodroutes
{RouteConfig} request routesinterceptors?
{Interceptors} functions to change request or response parameters, readdata
{any} mock data of requestentities?
Object<headers | query | params | body> object that helps in data retrievalinterceptors?
{Interceptors} functions to change request or response parameters, readinterface Entities {
headers?: { [string]: string | number };
query?: { [string]: string | number };
params?: { [string]: string | number };
body?: any;
}
/** @type {import('mock-config-server').MockServerConfig} */
const mockServerConfig = {
configs: [
{
path: '/user',
method: 'get',
routes: [
{
entities: {
headers: { 'name-header': 'Nursultan' }
},
data: { emoji: '🦁', name: 'Nursultan' }
},
{
entities: {
headers: { 'name-header': 'Dmitriy' }
},
data: { emoji: '☄', name: 'Dmitriy' }
}
]
}
]
};
module.exports = mockServerConfig;
Now you can make a request with an additional header and get the desired result
fetch('http://localhost:31299/user', {
headers: { 'name-header': 'Nursultan' }
})
.then((response) => response.json())
.then((data) => console.log(data)); // { emoji: '🦁', name: 'Nursultan' }
Entity for connecting statics to the server, like HTML, JSON, PNG, etc.
string
path to your static filesObject<{prefix, path}
prefix
{string} path prefix for requestpath
{string} path to your static filesArray<string | Object<{prefix, path}>>
Object with settings for CORS. You can flexibly configure the required origin, methods, headers, credentials, maxAge for the entire server. If you do not specify CORS
settings, then it will be disabled.
origin
{string | RegExp | Array<string | RegExp> | Function | Promise } available origins from which requests can be mademethods?
{Array<GET | POST | DELETE | PUT | PATCH>} available methods (default: *
)headers?
{Array} available methods (default: *
)credentials?
{boolean} param tells browsers whether to expose the response to the frontend JavaScript code (default: true
)maxAge?
{number} how long the results can be cached (default: 3600
)Functions to change request or response parameters
request?
(params) => voidresponse?
(data, params) => anyparams
request
request objectdata
{any} mock data of requestparams
request
request objectresponse
response objectsetDelay
(delay) => Promise
delay
{number} seconds of delay timesetStatusCode
(statusCode) => void
statusCode
{number} status code for response
☄️ debabin |
👹 MiaInturi |
🐘 RiceWithMeat |
FAQs
Tool that easily and quickly imitates server operation, create full fake api in few steps
The npm package mock-config-server receives a total of 49 weekly downloads. As such, mock-config-server popularity was classified as not popular.
We found that mock-config-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.