Adrien Marquès f4d46a961b | ||
---|---|---|
cnf | ||
src | ||
.gitignore | ||
LICENSE | ||
README.md | ||
package.json | ||
tsconfig.json |
README.md
| API mixer |
Simple REST API mixer as a service. A minimal service will be deployed on your local port 8000
, all incoming data has to be sent by POST fields (e.g. form-data, x-www-form-urlencoded). The output is a application/json set.
Project Set up
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.
1. Install dependencies
Go into the project's folder and run :
$ npm i
2. 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
.
3. Launch server
You need to have
node
installed.
Launch the server with the following command (inside the project's folder) :
$ node dist/main.js
Project fast start
This command will build and run the whole project :
$ npm run build;
$ npm start;
Test the API
You can now use Postman or whatever API client or web browser at 127.0.0.1:8000
. The only allowed request method is GET and accepts the research field in a query parameter named 'q'.
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.