Coding tasks - FE library
Library providing a mock server for FE interview coding tasks.
Notes
This package is runnable and contains simple server that provide necessary data and authentication service for the purpouse of the Front-end interview tasks.
It requires node >= 14.15.0
SERVER FEATURES
Routes
Here are all the default routes.
Plural routes
GET /flights
GET /flights/1
POST /flights
PUT /flights/1
PATCH /flights/1
DELETE /flights/1
Singular routes
GET /flights
POST /flights
PUT /flights
PATCH /flights
Filter
Use .
to access deep properties
GET /flights?legs.[0].stopCount=2&legs.[0].durationInMinutes=1810
GET /flights?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 /flights?_page=7
GET /flights?_page=7&_limit=20
10 items are returned by default
Sort
Add _sort
and _order
(ascending order by default)
GET /flights?_sort=views&_order=asc
GET /flights/1/comments?_sort=votes&_order=asc
For multiple fields, use the following format:
GET /flights?_sort=user,views&_order=desc,asc
Slice
Add _start
and _end
or _limit
(an X-Total-Count
header is included in the response)
GET /flights?_start=20&_end=30
GET /flights/1/comments?_start=20&_end=30
GET /flights/1/comments?_start=20&_limit=10
Works exactly as Array.slice (i.e. _start
is inclusive and _end
exclusive)
Operators
Add _gte
or _lte
for getting a range
GET /flights?views_gte=10&views_lte=20
Add _ne
to exclude a value
GET /flights?id_ne=1
Add _like
to filter (RegExp supported)
GET /flights?title_like=server
Full-text search
Add q
GET /flights?q=internet
Relationships
To include children resources, add _embed
GET /flights?_embed=comments
GET /flights/1?_embed=comments
To include parent resource, add _expand
GET /comments?_expand=post
GET /comments/1?_expand=post
To get or create nested resources (by default one level, add custom routes for more)
GET /flights/1/comments
POST /flights/1/comments