
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
mup-node-mock-server
Advanced tools
File based Node API mock server
This plugin requires Node ~0.12.7
or higher
brew install node
npm install node-mock-server --save-dev
node app.js
In your project's root, add a file named for example app.js
.
var mockServer = require('node-mock-server');
mockServer(options);
Type: String
Default value: './rest'
A string value that is used to define the path to the rest API folder.
Type: String
A string value that is used to define the root directory (__dirname).
Type: String
Default value: Api mock server
A string value that is used to define the title of the specification page.
Type: Number
Default value: 1
A number value that is used to define the API version.
Type: String
Default value: http://localhost:3001
A string value that is used to define the API url.
Type: String
Default value: /rest/v1
A string value that is used to define the path under which the API will be available.
Type: Number
Default value: 3001
A number value that is used to define the port.
Type: String
A string value that is used to define the private key for ssl.
Type: String
A string value that is used to define the certificate for ssl.
Type: String|Array
Optional
A string or array that is used to define where the response functions are located.
Type: Object
Default value: {}
A object that is used to define the global response headers. Will add the given headers to all responses.
Type: String
Default value: application/json
A string that is used to define the header "Content-Type".
Type: String
Default value: X-Total-Count
A string that is used to define the header "Access-Control-Expose-Headers".
Type: String
Default value: *
A string that is used to define the header "Access-Control-Allow-Origin".
Type: String
Default value: GET, POST, PUT, OPTIONS, DELETE, PATCH, HEAD
A string that is used to define the header "Access-Control-Allow-Methods".
Type: String
Default value: origin, x-requested-with, content-type
A string that is used to define the header "Access-Control-Allow-Headers".
Type: Object
Optional
A object that is used to define the swagger import.
Type: String
Default value: http
A string that is used to define the protocol for the swagger import curl.
Type: String
Optional
A string that is used to define the basic auth user for the swagger import curl.
Type: String
Optional
A string that is used to define the basic auth password for the swagger import curl.
Type: String
Required
A string that is used to define the host for the swagger import curl.
Type: String
Default value: 80
A string that is used to define the port for the swagger import curl.
Type: String
Default value: ``
A string that is used to define the path for the swagger import curl.
Type: String
Required
A string that is used to define the destination path for the swagger import.
Type: String
Default value: ``
A string that is used to define the part of the swagger imported methods path which should be removed.
Type: Boolean
Default value: true
A boolean that is used to decide to create an expected response error file or not.
Type: Boolean
Default value: true
A boolean that is used to decide to create an expected response empty file or not.
Type: Boolean
Default value: true
A boolean that is used to decide to replace an old description with the new (imported) description or not.
Type: String
A string that is used to define where the imported response functions are located.
var mockServer = require('node-mock-server');
mockServer({});
var mockServer = require('node-mock-server');
mockServer({
restPath: __dirname + '/mock/rest',
dirName: __dirname,
title: 'Api mock server',
version: 2,
urlBase: 'http://localhost:3003',
urlPath: '/rest/v2',
port: 3003,
funcPath: __dirname + '/func',
headers: {
'Global-Custom-Header': 'Global-Custom-Header'
},
swaggerImport: {
protocol: 'http',
authUser: undefined,
authPass: undefined,
host: 'localhost',
port: 3001,
path: '/src/swagger/swagger-demo-docs.json',
dest: dest,
replacePathsStr: '/v2/{baseSiteId}',
createErrorFile: true,
createEmptyFile: true,
overwriteExistingDescriptions: true,
responseFuncPath: __dirname + '/func-imported'
}
});
|- group
|--- #path
|--- #path#{param}
|----- method (GET, POST, DELETE ...)
|------- mock
|--------- success.json
|--------- success.headers.json
|--------- error.json
|--------- error-401.json
|------- desc.json
|------- request_schema.json
|------- response_schema.json
For example call GET "/products/superProductCode/?currentPage=1" Config in mock response Response will be:
{
"currentPage": 1,
...
}
For example call GET "/products/superProductCode/?currentPage=2" Config in mock response Response will be:
{
"productCode": "superProductCode"
...
}
options.headers
object to define global response header*.header.json
beside the expected response filePlease see the Releases
FAQs
File based Node API mock server
We found that mup-node-mock-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.