Simple api for test automation practice using HAI Server Inspired from JSON Server
- Node >= 10.0 How install Node
- yarn >= 10.22 How install Yarn
Install dependencies
yarn install
Start Api server
yarn init:server
POST http://localhost:3000/auth/login
with the following data.
Note: We can pick any user data from the list of users of the auth.json file.
{
"email": "[email protected]",
"password":"nilson"
}
You should receive an access token with the following format
{
"access_token": "<ACCESS_TOKEN>"
}
You should send this authorization with any request to the protected endpoints
Authorization: Bearer <ACCESS_TOKEN>
Based on the previous db.json
file, here are all the default routes.
/users
/articles
/authors
/comments
GET /users
GET /users/1
POST /users
PUT /users/1
PATCH /users/1
DELETE /users/1
Use .
to access deep properties
GET /users?age=35&gender=female
GET /users?id=1&id=2
Use _page
and optionally _limit
to paginate returned data.
In the Link
header you'll get first
, prev
, next
and last
links.
GET /users?_page=7
GET /users?_page=7&_limit=20
10 items are returned by default
Add _sort
and _order
(ascending order by default)
GET /users?_sort=age&_order=asc
For multiple fields, use the following format:
GET /users?_sort=age,gender&_order=desc,asc
Add _start
and _end
or _limit
(an X-Total-Count
header is included in the response)
GET /users?_start=20&_end=30
Works exactly as Array.slice (i.e. _start
is inclusive and _end
exclusive)
Add _ne
to exclude a value
GET /users?id_ne=1
Add _like
to filter (RegExp supported)
GET /users?name_like=Taylor
Add q
GET /users?q=SILODYNE