Sample Express.js API that retrieves customers and pagination information
759
This is a sample backend API that offers one endpoint:
This endpoint accepts four query parameters, as listed below.
page (optional; current page - default is 1)limit (optional; number of customers to be shown per page - default is 10)size (optional; filter customers by size: 'Small', 'Medium', 'Enterprise', 'Large Enterprise', 'Very Large Enterprise' - default is 'All')industry (optional; filter customers by business industry: 'Logistics', 'Retail', 'Technology', 'HR', 'Finance' - default is 'All')Below is an example of how the request URL would look like if you wanted to retrieve ten medium-sized customers from the technology industry on page two:
http://localhost:3001/customers?page=2&limit=10&size=Medium&industry=technology
If there are customers in the database, the following JSON structure should be returned after a successful request.
{
"customers": [
{
"id": 1,
"name": "Thompson, Zboncak and Mueller",
"employees": 850,
"contactInfo": null,
"size": "Medium",
"industry": "Technology",
"address": {
"street": "988 Kimberly Fort Apt. 921",
"city": "Lake Tracy",
"state": "Connecticut",
"zipCode": "07115",
"country": "United States of America"
}
},
{
"id": 2,
"name": "Americas Inc.",
"employees": 200,
"contactInfo": {
"name": "John Smith",
"email": "[email protected]"
},
"size": "Medium",
"industry": "Technology",
"address": {
"street": "5099 Murray Inlet",
"city": "South Tiffany",
"state": "Kentucky",
"zipCode": "08496",
"country": "United States of America"
}
},
...
],
"pageInfo": {
"currentPage": 2,
"totalPages": 20,
"totalCustomers": 199
}
}
Notes:
null when the customer doesn't have contact or address information in the database;size attribute in the response for each customer is dynamically determined based on the number of employees according to the specified criteria:
industry attribute corresponds to the business sector the company belongs to and can be one of the following: Logistics, Retail, Technology, HR, Finance;400 Bad Request status code for invalid request parameters, such as negative or non-number values for page or limit, or unsupported values for size or industry.The API also has a Swagger documentation, which can be accessed via the URL http://localhost:3001/api-docs/, as far as the backend server is up and running.
Content type
Image
Digest
sha256:7bfc4f814…
Size
409.5 MB
Last updated
3 months ago
docker pull wlsf82/engagesphereserver:amd64