0% found this document useful (0 votes)
20 views

Dev Middleware

The document describes requirements for a REST API for an address book app. It specifies middleware endpoints to GET a list of contacts and details of a single contact, and to DELETE a contact. It provides details on response formats and statuses for each endpoint.

Uploaded by

Christian Muro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Dev Middleware

The document describes requirements for a REST API for an address book app. It specifies middleware endpoints to GET a list of contacts and details of a single contact, and to DELETE a contact. It provides details on response formats and statuses for each endpoint.

Uploaded by

Christian Muro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Instructions

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.

You are provided with a fake database layer exported fakedatabase.js

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

For all requests


• The request to the URL path different than the expected ones would get the 404
Not Found HTTP status.
• The request to the supported URL path, but with an unexpected HTTP method
would get th e 405 Method Not Allowed HTTP status.

You might also like