This is an example of an API server written in a functional programming style.
It uses the cleanjs eslint plugin, which is pretty strict!
Start the server at http://localhost:3200
yarn start
When developing, you can use this to lint the code
yarn run lint
Responds with { items: [...] }
Requires the query param id
Responds with { message: :message, item: :item }
Requires the query param item
Responds with { message: :message, item: :newItem }
Requires the query param id
Responds with { message: :message }
This is just a very simple example - but a working one - while I learn FP.
I realize that it's not RESTful for the API to use HTTP GET
for /items/add
and /items/delete
,
however this is just a proof of concept and I didn't build a body parser yet.
I also wanted it to be super easy to test in a new browser tab.
The same reasoning applies to using query params instead of URL params for GET /items
and GET /items/delete
- I didn't build a URL param parser yet.
If I work on this more, it would naturally make sense to add a body parser, a URL param parser,
and not to use HTTP GET
for adding and deleting.
It would also make sense to add examples for HTTP PATCH
and HTTP PUT
.