1.0.12 • Published 6 years ago
simple-mockup-server v1.0.12
Simple Mockup Server
A simple and light mockup server designed to emulate responses from http requests and test communication.
Installation and execution
- Install with :
npm install -g simple-mockup-server
- Execute with :
simple-mockup-server
(Port can be specified with PORT parameter, by default uses 3001)PORT=portN simple-mockup-server
Set simple requests
- Create json file specifying the endpoint and the desired response (status is an optional parameter)
{
"endpoint": "NewTestEndpoint",
"status": 202,
"response" : {
"TEST": [
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}
]
}
}
Send a post petition to http://localhost:3001/createEndpoint with the specified json as body
(Simpler alternative without params) Send a post petition to http://localhost:3001/createEndpoint/ENDPOINTNAME with the desired response in the body
{
"TEST": [
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}
]
}
Access created endpoints
- To list all the requests endpoints: http://localhost:3001/listEndpoints
- Execute any petition type to http://localhost:3001/ENDPOINTNAME to get the specified response
Alternative way to set and edit simple requests
- Open file httpPetitions.json
- Edit/add/delete any requests (All requests must be in one line with the same structure as before)
Instructions to add functions with logic to the default configuration
- Create function in /controller/mockupController.js
- Set endpoint location in /routes/routes.js
Next steps
- Add similar functionality for websockets