First of all this REST API app is about to allow users to create and maintain custom collections of Hacker News stories.
First we open two terminals.
Write a command npm i
to install packages and then
write a command docker-compose up
which connects us to the Postgres database.
Write a command npm run start
which connects us to the http://localhost:3000 server.
All Requests are tested on Postman
This request creates a new user depending on the request email and password and stores him into a database and as a result, returns the API, which contains the endpoint of the id, email, and JWT token of the user.
This request finds an existing user and checks if the email and password are correct, and give us the same API endpoint as in the registration.
This request finds all users who are in the database.
This request finds an existing user in the database and gets us an endpoint with his information.
This request updates the user if a user is authorized, and the request body is with all parameters which are email and password.
This request updates the user as same as PUT but we can update just one property email or password.
This request deletes the user if a user is authorized and after that, it deletes all collections that deleted user had.
This request creates a new collection depending on the request name for an authorized user.
This request finds all collections which are in the database.
This request finds an existing collection in the database and gets us an endpoint with his information.
This request updates the collection if a user is authorized, and the request body is with all parameters, the name.
This request updates the collection as same as PUT.
This request deletes the collection if a user is authorized and after that, it deletes all stories that deleted collection had.
This request fetches the story into the collection and database and fetch also comments on this story.
This request finds all stories which are in the database.
This request finds an existing story in the database and gets us an endpoint with its information.
This request returns endpoint of comments on stories.
This request finds an existing comment in the database and gets us an endpoint with its information.
We can find tests in folder ./spec and we started test by command npm test
.