simple-json-replay-server
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "simple-json-replay-server", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"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.", | ||
@@ -18,3 +18,6 @@ "main": "main.js", | ||
], | ||
"author": "Jeff Duan", | ||
"author": { | ||
"name" : "Jeff Duan", | ||
"email": "realdah@gmail.com" | ||
}, | ||
"license": "MIT", | ||
@@ -21,0 +24,0 @@ "dependencies": { |
@@ -1,14 +0,15 @@ | ||
# Simple JSON Replay Server (Not yet published to npm, still working on it) | ||
# Simple JSON Replay Server | ||
Pefect companion with angular 1/2 development, and unit mock testing. | ||
### It is not a Restful Json Server | ||
## 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 url and query parameters and return response you expect? | ||
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 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. | ||
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. | ||
Isn't it overkill? if we just need a mock server to help us during development locally and once deployed, it will never bother again. | ||
Isn't it overkill? if we just need a mock server for development and unit testing. | ||
Or, if you have legacy backend API design, which are not strictly following restful specifications. | ||
### Simple Features: | ||
## Simple Features | ||
* **Simple command** to launch it in any avaialbe port with zero configuration. | ||
* **Simple command** to launch it with optional port and folder configuration. | ||
* **Easy to maintain data** Put a url and a response json in your replay data folder and you should get it right away. | ||
@@ -20,1 +21,72 @@ * **Advanced features** to allow you set more matching rules including request parameter, method, header, cookie etc. | ||
## How to start | ||
> **Install to your package.json** | ||
``` | ||
npm install simple-json-replay-server --save-dev | ||
``` | ||
> **Create app_mock folder under your application root** | ||
go to your application root folder, where it has package.json & your node_modules folder. | ||
``` | ||
mkdir app_mock | ||
``` | ||
> **Create mock data config files** | ||
Create a json file, eg. **_example.json_** inside of **_app_mock_** folder, you can create **any layer of sub folders to hold this file**. | ||
Once start replay server, you can hit <http://localhost:8008/test> to see the result. | ||
Please note: _you are able to config a different port number if it conflicts._ | ||
Example: | ||
``` | ||
{ | ||
"request" : { | ||
"url": "test", | ||
"method" : "get" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"data" : { | ||
"message" : "you made it!" | ||
} | ||
} | ||
} | ||
``` | ||
> **Start the replay server** | ||
``` | ||
node node_modules/simple-json-replay-server/src/main.js | ||
``` | ||
## Integrate with your development work flow | ||
As we all know, nowadays, most of frontend projects have been completely seperated from backend projects. | ||
When we develop frontend application, we often tend to mock the data either directly in the code or hard-coded in backend service before implemented, which will requires some code changes during integration phase. And more often it is not easy to setup mock data which can cover many business scenarios. | ||
With this simple json replay server approach, **your code is always the same code which you will use in production**, and in local development environment, you can route all your backend restful service calls to this replay server and thus you can run and play with your frontend application without **ANY dependency** on your backend server. | ||
I will take two most popular frontend build tools/solutions for example: | ||
1. **Webpack** (new fashionable toy) | ||
2. **Grunt** (old world favorite , **Gulp** as well) | ||
### **Webpack** | ||
**Webpack** based solution is gaining more popularity, and both angular 2 official and one of most popular tools - **angular-cli** are all using webpack as their build tool. | ||
<To Be Edited> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10477
91