Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-json-replay-server

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-json-replay-server - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

test/match/matchHeaderTest.js

3

app_mock/example.1.json

@@ -5,4 +5,3 @@ {

"query" : {
"bb" : 123,
"aa" : 345
"bb" : 123
}

@@ -9,0 +8,0 @@ },

{
"name": "simple-json-replay-server",
"version": "0.0.10",
"version": "0.0.11",
"description": "A simple json replay server which can be used for standalone frontend web application (angular especially) when development. Simply put the url & parameters & response json data, then hit the url in browser or from your web application, whenever it matches the url and parameters, it will return the best match json data.",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -6,3 +6,3 @@ # Simple JSON Replay Server ❤️ [![Build Status](https://travis-ci.org/realdah/simple-json-replay-server.svg?branch=master)](https://travis-ci.org/realdah/simple-json-replay-server) [![npm version](https://badge.fury.io/js/simple-json-replay-server.svg)](https://badge.fury.io/js/simple-json-replay-server) [![Node version](https://img.shields.io/node/v/simple-json-replay-server.svg?style=flat)](http://nodejs.org/download/)

## It is not a Restful Json Server
Have you spent a lot of time trying to find a **simple straight-forward file based json replay server** which will just matching path and query parameters and return response which matching you expect?
Have you spent a lot of time trying to find a **simple straight-forward file based json replay server** which will return json responses by matching some simple filtering criteria in requested parameters (such as query, headers, post body etc)?

@@ -46,3 +46,3 @@ You probably will be disappointed, because not all but at least majority of them are fancy shinning restful style severs which either return dynamic json in memory or manipulate some text based db files. And obviously, they will all require you to send standard restful style requests and then response with some dynamic results which you might have to think hard to set it up.

Create a json file, eg. **_example.json_** inside of **_app_mock_** folder, you can create **any layer of sub folders to organize your mock data files**. Our application only look for files ending with ".json" in app_mock folder.
Create a json file, eg. **_example.json_** inside of **_app_mock_** folder, you can create **any layer of sub folders to organize your mock data files**. The mock server will only look for files ending with ".json" in app_mock folder recursively.

@@ -107,5 +107,5 @@ Once start replay server, you can hit <http://localhost:8008/test> to see the result.

You can define as many as mock data configs which map to the same path. Then, you can define more filtering rules which can narrow down the results.
You can define more than one mock data which are mapping to the same path. And then, you should define different filtering rules which can narrow down the results.
However, if more than one mock data match the same number of filtering criteria (for query/body, each key is consider as seperate criteria), we will not guarantee which one will return.
However, if more than one mock data match the same number of filtering criteria (for query/body, each key is consider as seperate criteria), we will not guarantee which mock data will be returned.

@@ -118,3 +118,4 @@

query | key value pairs | Yes | Default as **undefined**. You can think about this is a filtering logic. As long as you defined a key-value, it will only allow request which contains this query parameter and same value to pass through.
body | a json map | Yes | Default as **undefined**. you can have partial values in multiple layers, it will only try to match partial branch of the value till the end. So far, only support **json body** (application/json) & **form-urlencoded** (application/x-www-form-urlencoded).
body | a json map | Yes | Default as **undefined**. you can have partial values in multiple layers, it will only try to match partial branch of the value till the end. So far, only support **json body** (application/json) & **form-urlencoded** (application/x-www-form-urlencoded) when **post**.
headers | key value pairs | Yes | default as undefined. Similiar to **query**, if you add any thing in here, it will filter out the data with headers having specific value.

@@ -245,1 +246,7 @@ ### ✦ Response

## Release Note
Version | Description
---------|----------
0.0.10 | Include **body** mapping for **json body** (application/json) & **form-urlencoded** (application/x-www-form-urlencoded)
0.0.11 | support filtering by **headers** value.

@@ -44,3 +44,3 @@ var express = require('express');

error: 'Can not find matching mock data',
req: _.pick(req, 'path', 'method', 'query', 'body') //'cookies', 'headers'
req: _.pick(req, 'path', 'method', 'query', 'body', 'headers')
});

@@ -47,0 +47,0 @@ }

@@ -44,4 +44,6 @@ var _ = require('underscore');

var score = queryScore + bodyScore;
var headerScore = util.partialContains(headers, mockDataConfig.request.headers);
var score = queryScore + bodyScore + headerScore;
if(score >= bestScore) {

@@ -48,0 +50,0 @@ bestScore = score;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc