- Para ejecutar la aplicación, es necesario tener Docker instalado
- Crear un archivo
.env
en el root del proeycto que tenga la key de la api de superheros (hay un ejemplo en.env.example
) - Crear un archivo
.env.local
en la carpeta/frontend
que tenga la dirección al backend (por ahora debería ser:NEXT_PUBLIC_API_URL=https://localhost:8080
) - En el root del proyecto, ejecutar el comando
docker-compose up
- Esperar hasta que se genere el build y corra el container
- Cuando veas un mensaje similar a
http4s v0.21.16 on blaze v0.14.14 started at https://0.0.0.0:8080/
, el server está corriendo y podés acceder a la API con la URL https://localhost:8080/
GET /cards/
- Trae todas las cartas en el sistema
{
"cards": [
{
"id": 69,
"name": "Batman",
"stats": {
"height": 178,
"weight": 77,
"intelligence": 81,
"speed": 29,
"power": 63,
"combat": 90,
"strength": 40
},
"image": "https://www.superherodb.com/pictures2/portraits/10/100/10441.jpg",
"biography": {
"fullName": "Terry McGinnis",
"publisher": "DC Comics"
}
}
]
}
GET /cards/:id
- Trae una carta en particular
{
"id": 69,
"name": "Batman",
"stats": {
"height": 178,
"weight": 77,
"intelligence": 81,
"speed": 29,
"power": 63,
"combat": 90,
"strength": 40
},
"image": "https://www.superherodb.com/pictures2/portraits/10/100/10441.jpg",
"biography": {
"fullName": "Terry McGinnis",
"publisher": "DC Comics"
}
}
GET /cards/publishers
- Trae una lista de todos los publishers que tienen las cartas del sistema
{
"publishers": [
"DC Comics",
"Marvel"
]
}
POST /cards
- Agrega una carta al sistema buscando al superheroe con ese id.
Es solo para admins, va en un header "Authorization" el token del administrador.
Authorization: Bearer <token>
body:
{ "id": 69 }
response:
{
"id": 69,
"name": "Batman",
"stats": {
"height": 178,
"weight": 77,
"intelligence": 81,
"speed": 29,
"power": 63,
"combat": 90,
"strength": 40
},
"image": "https://www.superherodb.com/pictures2/portraits/10/100/10441.jpg",
"biography": {
"fullName": "Terry McGinnis",
"publisher": "DC Comics"
}
}
GET /superheros/name/:searchName
- Trae superheroes que tienen ese searchName dentro de su nombre
GET /superheros/name/man
repsonse:
{
"superheros": [
{
"id": 641,
"name": "Superboy",
"stats": {
"height": 170,
"weight": 68,
"intelligence": 75,
"speed": 83,
"power": 95,
"combat": 60,
"strength": 95
},
"image": "https://www.superherodb.com/pictures2/portraits/10/100/789.jpg",
"biography": {
"fullName": "Kon-El / Conner Kent",
"publisher": "DC Comics"
}
}
]
}
GET /superheros/:id
- Trae superheroe con ese id
{
"id": 641,
"name": "Superboy",
"stats": {
"height": 170,
"weight": 68,
"intelligence": 75,
"speed": 83,
"power": 95,
"combat": 60,
"strength": 95
},
"image": "https://www.superherodb.com/pictures2/portraits/10/100/789.jpg",
"biography": {
"fullName": "Kon-El / Conner Kent",
"publisher": "DC Comics"
}
}
GET /decks/:id
- Trae el mazo con ese id
{
"id": 1,
"name": "Marvel Deck",
"cards": []
}
GET /decks/
- Trae todos los mazos
{
"decks": [
{ "id": 1, "name": "Marvel Deck", "cards": [] }
]
}
PATCH /decks/:id
- Agrega una carta al mazo
body:
{ "cardId": 1 }
response:
{
"id": 1,
"name": "Marvel Deck",
"cards": []
}
DELETE /decks/:id
- Borra el mazo con ese id
POST /users/
- Crea un usuario con determinado rol
body:
{
"userName": "usuarioDePrueba",
"password": "passwordDePrueba",
"role": "Admin" // | "Player" // esto cambiaría
}
response:
{
"userName": "usuarioDePrueba",
"id": 5118330560133248253,
"accessToken": "<token>"
}
POST /users/login
- Devuelve un token que identifica al usuario para que pueda operar en el sistema.
body:
{
"userName": "usuarioDePrueba",
"password": "passwordDePrueba"
}
response:
{
"userName": "usuarioDePrueba",
"id": 5118330560133248253,
"accessToken": "<token>"
}