[Docs] README

pull/9/head
sundowndev 2018-08-30 11:15:19 +02:00
parent ee224bf31a
commit 35a216ca69
2 changed files with 88 additions and 31 deletions

119
README.md
View File

@ -1,52 +1,109 @@
# interview-v2
Fetch posts using a REST API.
Simple REST API application based on Expressjs to fetch blog posts with custom endpoints and responses.
### Installation (docker)
~~~
$ git clone
$ cd interview-v2/
$ docker-compose build
~~~
### Installation
...
~~~
$ npm install
~~~
### Usage
...
Launch server
~~~
$ node index.js
~~~
Launch application with Docker
~~~
$ docker-compose up -d
~~~
### API endpoints
...
| Method / Route | Resource | Description |
| --------------------- | ------------------ | ------------ |
| `GET` /posts | Posts,Users | Fetch posts and their users |
The `/posts` route can receive extra parameters :
| Parameter | Values/type | Description |
| --------------------- | ------------------ | ------------ |
| user_pos | eq,cancer,cap,arctic,antarctic | Search posts by user position |
| user_id | *int* | Search posts by user id |
### Response
Example response for posts
The response follows the [Google JSON guide](https://google.github.io/styleguide/jsoncstyleguide.xml).
**Success response return data**
```json
[
{
"title": "<h1>title</h1>",
"body": "<p>body</p>",
"user": {
"id": 1,
"firstname": "Raphael",
"lastname": "Cerveaux",
"email": "raphael@crvx.fr",
"comments_count": 3,
"geopos": "latitude 23° 27' sud"
{
"data": [
{
"id": 1001,
"name": "Wing"
}
},
{
"title": "<h1>title2</h1>",
"body": "<p>body</p>",
"user": {
"id": 1,
"firstname": "Raphael",
"lastname": "Cerveaux",
"email": "raphael@crvx.fr",
"comments_count": 3,
"geopos": "latitude 23° 27' sud"
}
}
]
]
}
```
**Error response return error**
```json
{
"error": {
"code": 404,
"message": "ID not found"
}
}
```
Here is an example response for `/posts` :
```json
{
"data": [
{
"id": 1,
"title": "<h1>sunt aut facere repellat provident occaecati excepturi optio reprehenderit</h1>",
"body": "<p>quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto</p>",
"user": {
"id": 1,
"firstname": "Raphael",
"lastname": "Cerveaux",
"email": "raphael@crvx.fr",
"comments_count": 3,
"pos": {
"lat": "-37.3159",
"lng": "81.1496"
}
}
}
]
}
```
### Architecture
The application fetch resources from an external REST API and formats the response for the end user.
![](https://i.imgur.com/vRJhQMP.png)
The Docker configuration is composed of 2 layers. It uses a node image to launch the app and Nginx.
-----
## Exercice

View File