Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/romaleev/nodejs-queue-service

Node.js API queueing service
https://github.com/romaleev/nodejs-queue-service

api babel node nodejs nodemon queue

Last synced: about 1 month ago
JSON representation

Node.js API queueing service

Awesome Lists containing this project

README

        

# Node.js API queuing service

There are 3 different APIs the service has to interface with:

1. Shipments API [GET]
Accepts a query with 9-digit order numbers and returns a set of products (envelope, box or pallet) equivalent to the last digit.
2. Track API [GET]
Accepts a query with 9-digit consignment number and returns one of the following tracking statuses: NEW, IN TRANSIT, COLLECTING, COLLECTED, DELIVERING, DELIVERED.
3. Pricing API [GET]
Accepts a query with ISO-2 country code and returns a randomized floating number between 1 and 100.

There are 2 services:

1. Query service [POST]:
- Exposes a method that accepts a collection of API requests {'API': 'query'}.
- Makes calls to corresponding APIs.
- Returns a complete set of responses upon receiving all API responses.
2. Queue query service [POST]:
- Exposes a method that accepts a collection of API requests {'API': 'query'}.
- API calls should be throttled and bulked into 1 request per respective API.
- Makes a queue of calls with threshold of maximum 5 concurrent requests per API endpoint.
- Returns a complete set of responses upon receiving all corresponding API responses.

Author: Roman Malieiev

Project consists of two builds:
- production optimised
- development with source change watchers

Tech stack:
- Node.js
- Babel for ES6 support with ESLint
- Nodemon development build
- Frisby tests

## Installation

1. Install Node.js/npm
2. Navigate to the current folder
3. Run:

`npm install`

## Running

Run in development mode:

npm start

Build for production:

npm run build

Following urls would be available:

- http://localhost:8080/shipments [GET] - Shipments API
- http://localhost:8080/track [GET] - Track API
- http://localhost:8080/pricing [GET] - Pricing API
- http://localhost:8080/service [POST] - Query service
- http://localhost:8080/service-queue [POST] - Queue query service

**NOTE**: see tests for requests examples.

Test:

npm start
npm test

## Questions

#### With the above solution, can you imagine a scenario where unnecessary calls to either one of the APIs will happen? If so, how could you solve this?

We can implement caching within some time