A REST API to store informations about the survivors.
- Register survivor
- Update survivor location
- All Reports
- Flag survivor as infected
.
├── config
│ └── config.js
│ └── datasource.js
├── controllers
│ ├── itens.js
│ ├── person.js
│ ├── person_itens.js
├── models
│ ├── itens.js
│ ├── person.js
│ ├── person_itens.js
├── routes
│ └── person.js
├── tests
├── app.js
└── index.js
└── package.json
- ES6
- NodeJS
- Express
- Sequelize
- PostgreSQL
Go to folder /doc and access the index.html file for more informations
METODO | ENDPOINT | FUNCTION |
---|---|---|
GET | /api/person | List all persons |
GET | /api/person/:id | List one person by id |
GET | /api/:id /person/ | List one person with it's items |
POST | /api/person | Create a new survivor |
POST | /api/person/:id/report | Informs that survivor is infected |
PATCH | /api/person/:id | Update a survivor |
METODO | ENDPOINT | FUNCTION |
---|---|---|
GET | /api/report/person/infected | Informs the average of infected people |
GET | /api/report/person/healthy_people | Informs the average of non-infected people |
GET | /api/report/person/average_person_inventory | Informs the average of the quantity of items per person |
GET | /api/report/infected_points | Informs the total points lost in items that belong to infected people |
You can see the API on Heroku. [Heroku Demo] (https://zssn-back-end.herokuapp.com/api/person)
The project needs a relational database because of the relationship rules it needs. The image below shows these relationships
## Running locallyFirst of all you'll postgresql installed
> sudo apt-get update
> sudo apt-get install postgresql
Download NodeJs
> sudo apt-get update
> sudo apt-get install nodejs
Clone the project
> git clone https://gitlab.com/carlosjsl95/survivorProject.git
Install the project dependencies
> npm i
Then create a database named survivor on postgres and change the options in the file config.js for your password and user
export default{
database: 'survivor',
username: 'postgres', <<<< here
password: 'postgres', <<<< here
params: {
dialect: 'postgres',
define: {
underscored: true,
},
},
};
And finally run it locally
> npm start
Then access http://localhost:7000/{endpoint_name}
;
You can run tests with the following commands
> npm test-integration
> npm test-unit
- Implement trade's endpoint