Mockfoundry
The Mocking-First RESTful Server
The Mocking-First RESTful Server
- Ever wanted to prototype a UI and want a quick way of testing API/CRUD functionalities?
- Ever worked on a feature with external incomplete API dependencies?
- Ever wanted a very simple RESTful server with built-in CRUD operations?
Mockfoundry is an NPM library that hopes to answer the aforementioned questions.
Enough of all the boilerplate server and route setups needed to achieve the actual goal — doing something with/on the data.
Setup
Setup is straight forward:
- Install Library — npm i mockfoundry
- Require It — const Mock = require(‘mockfoundry’);
- Instantiate It — const instance = new Mock(1000);
- Start Server — instance.start();
- Done.
API
API is also straight forward. It follows the standard RESTful architecture with HTTP Methods along with the Actions accurately describing what exactly is happening to your data:
Actions
Actions are simple and descriptive as to what they do with the data:
- save — save data
- fetch — fetches data
- count — counts data
- update — updates data
- remove — removes data
Pseudo Examples
To have an idea of how API interact with your data, below are some examples of how a request to a Mockfoundry server will look like.
/**
* save example
*/
medthod: POST
url: http://localhost:1000/save/tweet
body: {
"content": "mockfoundry library article",
"date": "March 24, 2019",
"likes": 10,
"replies": 5,
"retweets": 2,
"shares": 5,
"handler": "kofi"
}
/**
* fetch example
*/
method: GET
url: http://localhost:1000/fetch/tweet?limit=1
/**
* count example
*/
medthod: GET
url: http://localhost:1000/count/tweet
/**
* update example
*/
method: PUT
url: http://localhost:1000/update/tweet
body: {
"filters": [
{
"field": "handler",
"op": "$eq",
"value": "kofi"
},
{
"field": "likes",
"op": "$eq",
"value": 10
}
],
"update": {
"likes": 15,
"articles": [
"medium",
"linkedin"
]
}
}
/**
* delete example
*/
method: DELETE
url: http://localhost:1000/remove/tweet
body: {
"filters": [
{
"field": "shares",
"op": "$eq",
"value": 5
}
]
}
Head over to Mockfoundry to read more about all the capabilities that come with it and start using it for your mocking and testing needs.