Docker used for Contanization
http://35.199.94.103/ link to test(temp)
This is a one week project where the objective is to create a Rest Api and a Cli using C and any supplemental library. This challange is an opportunity to take the first step towards the job market with 42.
Method | Uri |
---|---|
/ | GET |
/pokemon | GET |
/pokemon | POST |
/pokemon/$(id) | GET |
/pokemon/$(id) | PUT |
/pokemon/$(id) | DELETE |
-
Mongoose as a network library to accept http request
-
Mysql to stored our data into a relational database
-
Mysql C Lib to connect our C server into the database
-
Docker to separete our Api, Cli And Database in containers
-
Development tools such as git, gcc and make
-
- Whimsical a Web Application to make fluxograma
-
- Monday To plan priorities
-
- Notion To organize what and when to study a subject
-
Tools to test our api
The image is privated but in the future i wish to lauch it.
Make sure you have Docker installed in your environment
I'm not using docker-composer since this was a one week project, but i will implement it in the next project
-
Images needed:
-
docker pull mysql docker pull ubuntu docker pull debian
-
Volumes:
-
docker volume create --name Logs docker volume create --name Database-volume
-
Build:
-
docker build -t api ./Api docker build -t cli ./Cli docker build -t my_sql ./Database
-
Network:
-
docker network create database_network
-
Run:
-
docker run --network database_network -v Database-volume:/var/lib/mysql --name=mysql_container my_sql #wait set up then close the terminal and open again, or use -d flag and wait a minute to give it time to start the database docker run -ti -d --network database_network --name=api_container -p 8000:8000 -v Logs:/Logs api #in the first time we set up api_container it can take 1 to 2 minutes since it will seed our database with some data from the Api https://pokeapi.co/ . Remove -d flag to see the proccess
-
Now the Api server is up and can be accessed throught localhost:8000
-
Try access localhost:8000/pokemon as a test. If the container connection stop it means the mysql doesn't finish its set up, just run
docker start api_container
again and the application will work normally -
You can use docker commands to manage the containers
-
docker stop [container] docker start [container] docker run -ti --rm --volumes-from api_container cli#open cli and navegate throught the logs
Host/Endpoint
Considere localhost:800 as the Host
-
-
Brief: Initial page Response: status 200 json with welcome message
-
-
-
Brief: Returns in json all the pokemons stored into the database Response:(json) [ { "id": 1, "gen": 1, "name": "Bulbasaur", "type": "Grass" }, { "id": 2, "gen": 1, "name": "Charmeleon", "type": "Fire" }, { "id": 3, "gen": 1, "name": "Blastoise", "type": "Water" } ... ... ... ]
-
-
-
Brief: Return a json array with the pokemon of the passed id, or status 404 if this pokemon doesn't exist in our database Response:(json) [ { "id" : 1, "gen": 1, "name": "Bulbasaur", "type": "Grass" } ]
-
-
-
Brief: Create a new pokemon into the database Request:(json) { "name": "my_new_pokemon", "type": "my_type", "gen": 3 } Response: status 202 in success status 500 or 400 in case of error
-
-
-
Brief: Update a pokemon of id with new values Request:(json) { "name": "my_new_pokemon", "type": "my_type", "gen": 1 } Response: status 200 in success status 500 in case of error
-
-
-
Brief: Delete pokemon of id Response: status 200 in success status 500 in case of error
-
Cli provides 3 interfaces
- Total Requests
- Show all Requests of a pair Method Uri
- Show information about an specific request
- You can press [space] to see the menu helper
- Navegate throught the table using w/s or up down
- Select an item with [enter]
- [backspace] to return to the previous page
- [q] to exit the application
- Gabriel (gsilva-v)
- Leonardo (lfilipe-)
Notion Most part of the links used is inside notion