Skip to content

Schveitzer/simple-api-jwt-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Api with jwt authentication for test automation practice

Simple api for test automation practice using HAI Server Inspired from JSON Server

Requirements

Getting started

Install dependencies

yarn install

Start Api server

yarn init:server

How to login?

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>

Captura-de-tela-de-2020-08-16-19-39-57

Routes

Based on the previous db.json file, here are all the default routes.

Routes

/users
/articles
/authors
/comments
GET    /users
GET    /users/1
POST   /users
PUT    /users/1
PATCH  /users/1
DELETE /users/1

Filter

Use . to access deep properties

GET /users?age=35&gender=female
GET /users?id=1&id=2

Paginate

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

Sort

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

Slice

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)

Operators

Add _ne to exclude a value

GET /users?id_ne=1

Add _like to filter (RegExp supported)

GET /users?name_like=Taylor

Full-text search

Add q

GET /users?q=SILODYNE

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published