ExPokeFight is a JSON API that returns information about a simulated battle between two pokemons. It's a project for a backend exercise from Brainn.co.
To clone and run this application, you'll need Git, PostgreSQL or an PostgreSQL image on Docker, Elixir and Erlang installed.
From command line:
# Clone this repository
$ git clone https://github.com/vbertazzo/expokefight
# Go into the repository
$ cd expokefight
# Install dependencies
$ mix deps.get
# Create and migrate your database
$ mix ecto.setup
# or you can run migration manually with
$ mix ecto.migrate
# Start server
$ mix phx.server
# Remember that you will need to start your PostgreSQL locally running on port 4000POST /api/battles
Body:
{
"pokemon1": "gengar",
"pokemon2": "ditto"
}201 Created
{
"battle": {
"date": "2022-02-08T17:21:38",
"defeated": {
"id": "1c1b01e1-898d-4cd5-9d84-9b7679ca7ca5",
"name": "ditto",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/132.png",
"type": "normal"
},
"id": "89bf78a2-6500-406a-963b-10de75f7a91f",
"victorious": {
"id": "d65dcb78-def2-464d-8c2f-90624f4a7949",
"name": "gengar",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/94.png",
"type": "ghost/poison"
}
}
}GET /api/battles/:id
200 OK
{
"battle": {
"date": "2022-02-08T17:21:38",
"defeated": {
"id": "1c1b01e1-898d-4cd5-9d84-9b7679ca7ca5",
"name": "ditto",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/132.png",
"type": "normal"
},
"id": "89bf78a2-6500-406a-963b-10de75f7a91f",
"victorious": {
"id": "d65dcb78-def2-464d-8c2f-90624f4a7949",
"name": "gengar",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/94.png",
"type": "ghost/poison"
}
}
}GET /api/battles
200 OK
{
"battles": [
{
"id": "89bf78a2-6500-406a-963b-10de75f7a91f",
"date": "2022-02-08T17:21:38",
"victorious": {
"id": "d65dcb78-def2-464d-8c2f-90624f4a7949",
"name": "gengar",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/94.png",
"type": "ghost/poison"
},
"defeated": {
"id": "1c1b01e1-898d-4cd5-9d84-9b7679ca7ca5",
"name": "ditto",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/132.png",
"type": "normal"
}
},
{
"id": "d19803da-24df-440b-8b6c-075eb87ff20c",
"date": "2022-02-08T17:37:53",
"victorious": {
"id": "adbf13e3-4e78-4c0b-ace9-851bf9a5913d",
"name": "pikachu",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/25.png",
"type": "electric"
},
"defeated": {
"id": "87211c58-944d-4c0c-a897-bece19daec96",
"name": "charmander",
"image": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/4.png",
"type": "fire"
}
}
]
}This project is MIT licensed.