New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mock-rest

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-rest

## Description & Features

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

mock-rest

Description & Features

Mocked Web Server, providing REST service driving by json-schema. Only run on ES7+.

Pre Install

node version 7.0.0+

Install

  npm install mock-rest

Sample


const mock = require('./index')('/api');

const user = {  //align json-schema
	type : 'object',
	properties : {
		id: {type: 'string'},
        username: {type : 'string'},
        tenents: {
        	type: 'array',
        	items: {type: 'integer'}
        }
	},
	required : ['id', 'username', 'tenents']
};

mock('/users',[{
	{ // get all
		path: '/',
		method : 'get',
		result : {
			type : 'array',
			items : user
		}
	},
	{ //one 
		path: '/:id',
		method: 'get',
		result: user
	},
	{ //create
		path: '/',
		method : 'post',
		body : {  //align json-schema
	        type:'object',
	        properties : {
	            username: {type : 'string'},
	            passwd: {type: 'string'},
	            tenant: {type: 'integer'}
	        },
	        required : ['username','passwd','tenant']
    	},
    	result : user
	}
}]);

mock.listen(3000);

Now, access site http://yourhost:3000/api

FAQs

Package last updated on 25 Nov 2016

Did you know?

Socket

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.

Install

Related posts