Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arthurgousset/mockapi
👷♀️ A simple mock API server for testing purposes.
https://github.com/arthurgousset/mockapi
api expressjs mock-server nodejs
Last synced: about 1 month ago
JSON representation
👷♀️ A simple mock API server for testing purposes.
- Host: GitHub
- URL: https://github.com/arthurgousset/mockapi
- Owner: arthurgousset
- Created: 2023-05-31T21:26:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-12T20:15:55.000Z (over 1 year ago)
- Last Synced: 2024-04-14T01:54:31.739Z (7 months ago)
- Topics: api, expressjs, mock-server, nodejs
- Language: JavaScript
- Homepage:
- Size: 164 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mock API
A simple mock API server for testing purposes.
## Get started
Start the mock API by typing this into your terminal:
```zsh
npm start
```To terminate the mock API server, press `Ctrl + C` in your terminal.
## Usage
### Mock endpoint
You can make HTTP POST requests with arbitrary JSON payloads:
+ to the `/mock` endpoint (at `http://localhost:3000/mock`), and
+ to the `/mock/echo` endpoint (at `http://localhost:3000/mock`).Nothing will happen with the JSON payload you submit, because the mock API server is not designed
to do anything with your request.For example, you can send the following HTTP POST request to the `/mock` endpoint:
```JSON
{
"text": "hello world"
}
```Regardless of the payload you send, if your request is successful, you should received a HTTP
response with the following text:```zsh
Mock request successful!
```## Debugging
If you're API server is running correctly, you should see a similar output in your terminal:
```zsh
> [email protected] start
> nodemon app.js[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
Server is up and running at http://localhost:3000 ...
```If you are not sure the mock API server is running, you can check by:
1. opening your browser at `http://localhost:3000`
2. typing `curl http://localhost:3000` in your terminal, or
3. sending an empty HTTP GET request to `http://localhost:3000` from your preferred API tool
(e.g. Postman)You will know your server is running correctly if you see the following message:
```zsh
Mock API server is running!
```If you are confused about what `nodemon` is, don't worry. `nodemon` is a tool that helps develop
node.js based applications by automatically restarting the node application when file changes in
the directory are detected. This simply means that you don't have to restart the mock API server
every time you make a change to the code. Every time you save a change to the code, `nodemon` will
automatically restart the mock API server for you so that you can see the changes you made.