Dev Middleware
Dev Middleware
1. You only have 24 hours to delivered the assessment to your RH recruiter, please send
an email to the recruiter account with copy to: [email protected]
2. You can code in any language allowed (javascript, nodejs, python, .net core, java
springboot)
3. Your code has to be delivered in a public Github link or a .zip/.rar including the
dependencies to run the project and send it to the email (instruction 1)
1. Programming Test
You are developing a REST API of an address book app. You were asked to implement a
middleware to fetch a list of contacts and to fetch details of a single contact and to delete a
given contact.
Instructions
Your implementation has to fulfil the requirements of HTTP endpoints using Middleware's
described below:
GET /contacts
• The response HTTP status should be: 200 OK.
• The response Content-Type header should be: application/json.
• The response body should be: a JSON array with details of all contacts as loaded
from the database (each contact has an ID, a name, a phone and an array of
strings addressLines).
• The contacts in the response body are sorted by their name, which means a contact
with the name of Abbigail Wunsch would be first and a contact with the name
of Zoila Daugherty II would be last.
• If the phrase URL query parameter is present:
o in the response body, filter out contacts with names matching phrase;
o the phrase and the contact's name are compared lowercase, which means
that both Theresa Gorczany and Zakary Mayer match the
following phrase=zA;
o If there are no contacts matching the phrase, then the response body
contains only an empty JSON array as there are no contacts to include in it.
o If the phrase is empty (phrase=), then the response has the 400 Bad
Request HTTP status and an empty response body.
GET /contacts/
• If a contact with ID value <contact-id> exists:
o the response HTTP status should be: 200 OK;
o the response Content-Type header should be: application/json;
o the response body should be: a JSON object with details of that contact
loaded from the database (ID, name, phone and an array of
strings addressLines).
• If a contact with ID value <contact-id> does not exist:
o the response HTTP status should be: 404 Not Found.
POST/contact/
• You have to create a new contact giving the following params (ID, name, phone,
address) in the header section, remember to use JSON schema
• Following you’ve created a contact you have to use the middleware concept (Next)
to print the host IP of the PC or laptop that created the new contact