Go to file
Adrien Marquès 84979e63c2 refactor according to the report 2018-11-30 19:11:38 +01:00
cnf POST to GET only | accept: application/json but HTML by default 2018-11-12 12:50:12 +01:00
src refactor according to the report 2018-11-30 19:11:38 +01:00
.gitignore POST to GET only | accept: application/json but HTML by default 2018-11-12 12:50:12 +01:00
LICENSE Initial commit 2018-10-17 16:06:39 +02:00
README.md update listening port in readme 2018-11-29 20:03:41 +01:00
package.json works with Carrefour.Items api 2018-10-23 20:59:33 +02:00
tsconfig.json works with Carrefour.Items api 2018-10-23 20:59:33 +02:00

README.md

| API mixer |

Simple REST API mixer as a service. A minimal service will be deployed on your local port 8080, the keywords has to be sent with the query field q. The output is a application/json set, if the header Accept: application/json is not set or does not specify json, it will render as a simplistic HTML webpage representing the results and images.

Summary

I. Prerequisites

You need node and npm installed. The project is written using typescript that allows type checking and other verifications before creating the real javascript code. Also it adds polyfills (c.f. babel) to ECMAScript that allows the use of class and other new ES features.

Then run the following command at the project's root to install necessary dependencies :

$ npm i

II. Easy Setup

This command will build and run the whole project :

$ npm run build;
$ npm start;

III. Test the API

You can now use Postman or whatever API client or web browser at 127.0.0.1:8080. The only allowed request method is GET and accepts the research field in a query parameter named 'q'. The console running the server will provide reactive and real-time details.

Example URL : http://127.0.0.1:8080/?q=Nutella that searches for the keyword "Nutella".

When called in a browser you will get a simple web page that is the representation of the results (with images).

When called with the header Accept: application/json, the result will represent the data as a JSON object.

IV. Detailed Setup

1. Transpile sources

Run the following command inside the project's folder :

$ npm run build

All source files of the src/ folder will be transpiled into the dist/ folder.

It is also possible to watch the typescript while developping and modifying files with the command npm run watch.

2. Launch server

You need to have node installed.

Launch the server with the following command (inside the project's folder) :

$ node dist/main.js