# GoalAim Backend
<div align="center">


</div>
## Table of Contents
- [Presentation](#presentation)
- [Installation](#installation)
- [Database](#local-db)
- [Server](#launch-server)
- [Unit Tests](#unit-tests)
- [Documentation](#documentations)
- [Swagger](#swagger)
## Presentation
Here the repo of the Rust server. \
The application will make call to the server to get the information.
## Installation
### Local db
You have to setup a local postgres db with docker :
```sh
# Install diesel
cargo install diesel_cli --no-default-features --features postgres
# creation du docker:
sudo docker run --name goalaim_db -d -p 5432:5432 -e POSTGRES_PASSWORD=admin postgres
# CMD for the end
# Connect yourself to the docker :
psql --host=0.0.0.0 -U postgres
# Always restart the docker :
sudo docker update --restart always goalaim_db
# In the docker :
CREATE DATABASE goalaim_db;
CREATE DATABASE test_db;
# In the .env at the root of the project
DATABASE_TEST_URL=postgres://postgres:admin@0.0.0.0/test_db
DATABASE_URL=postgres://postgres:admin@0.0.0.0/goalaim_db
PORT=8080
JWT_SECRET="celui qui lit ça est gay"
```
For Diesel set this in your .bashrc or .zshrc and then, restart your terminal
```sh
# relace user by the real name
export PATH="$PATH:/home/user/.cargo/bin"
```
To create the Table in the docker psql :
```sh
diesel migration run
```
To check if the table is created :
```sh
# Connection
psql --host=0.0.0.0 -U postgres
# Connect yourself to the db
\connect goalaim_db
# Check if table exist
SELECT * FROM users;
```
### Launch server
To launch the server run :
```sh
cargo build
# or directly
cargo run
```
## Unit Tests
To run the unit tests :
```sh
cargo test
```
## Documentations
To have the Documentation of the code :
```sh
cargo doc
```
Now you have to go to ${ACTUAL_PATH}/target/doc/goalaim/ and open the index.html in the browser.
### Swagger
You can have the swagger of our API routes in [Swagger](/Docs/API/swagger_spec.yaml)
You can have a preview of our swagger with the Swagger Preview extension in vscode.
## Contributors
You can contact us at:
- **Noeme Suisse** : noeme.suisse@epitech.eu
- **Victor Massonnat** victor.massonnat@epitech.eu
<table>
<tbody>
<tr>
<td align="center"><a href="https://github.com/noeme-suisse"><img src="https://avatars.githubusercontent.com/u/91609807?v=4" width="100px;" alt="Noeme Suisse"/><br/><sub><b>Noeme Suisse</b></sub></a><br/></td>
<td align="center"><a href="https://github.com/VidsSkids/"><img src="https://avatars.githubusercontent.com/u/60828505?v=4" width="100px;" alt="vic"/><br/><sub><b>Victor Massonnat</b></sub></a><br/></td>
</tr>
</tbody>
</table>