This is the backend for the Pokedex exercises.
- Clone this repository
- Install dependencies
- Create a .env file based on the example with proper settings for your local environment
- Create a database user with the same name and password as found in your .env file with CREATEDB privileges
- Run
npm run db:create
npm run db:migrate
npm run db:seed:all
npm start
Some of the API results have image URLs associated with them. You can get them
from this service. For example, if the service is hosted at
http://localhost:5000
, then http://localhost:5000/images/pokemon_snaps/5.svg
will show the image for the Pokemon with the image URL
/images/pokemon_snaps/5.svg
.
This is all about listing and creating Pokemon.
Successful response:
[
"fire",
"electric",
"normal",
"ghost",
"psychic",
"water",
"bug",
"dragon",
"grass",
"fighting",
"ice",
"flying",
"poison",
"ground",
"rock",
"steel"
]
This route returns an array of Pokemon. Those that have been captured will have their image returned. Otherwise a question mark image will be sent for the ones that are not captured. The information on each Pokemon is not detailed.
Successful response looks like this with more entries:
[
{
"id": 1,
"no": 1,
"name": "Bulbasaur",
"imageUrl": "/images/pokemon_snaps/1.svg",
"captured": true
},
// ...
]
This route returns detailed information about the Pokemon with the matching id in the route parameters.
Successful response looks like this for the given id:
{
"imageUrl": "/images/pokemon_snaps/1.svg",
"id": 1,
"no": 1,
"attack": 49,
"defense": 49,
"name": "Bulbasaur",
"type": "grass",
"moves": [
"tackle",
"vine whip"
],
"captured": true,
"createdAt": "2020-12-16T01:17:24.119Z",
"updatedAt": "2020-12-16T01:17:24.119Z"
}
This route accepts information to create a Pokemon.
The payload that you must send looks like this:
{
"no": 11,
"attack": 25,
"defense": 55,
"imageUrl": "/images/pokemon_snaps/11.svg",
"name": "Metapod",
"type": "bug",
"moves": [
"Tackle",
"Harden"
]
}
Successful response is the newly created Pokemon returned and looks like this:
{
"id": 150,
"no": 11,
"attack": 25,
"defense": 55,
"imageUrl": "/images/pokemon_snaps/11.svg",
"name": "Metapod",
"type": "bug",
"moves": [
"Tackle",
"Harden"
]
}
This route updates a Pokemon with the matching id in the route parameters.
The payload that you must send looks like this.
{
"id": 150,
"no": 11,
"attack": 25,
"defense": 55,
"imageUrl": "/images/pokemon_snaps/11.svg",
"name": "Metapod",
"type": "bug",
"moves": [
"Tackle",
"Harden"
]
}
Successful response is the updated Pokemon returned and looks like this:
{
"id": 150,
"no": 11,
"attack": 25,
"defense": 55,
"imageUrl": "/images/pokemon_snaps/11.svg",
"name": "Metapod",
"type": "bug",
"moves": [
"Tackle",
"Harden"
]
}
This route returns all the items as an array for the Pokemon matching the id in the route parameter.
Successful response looks like this:
[
{
"id": 1,
"happiness": 86,
"imageUrl": "/images/pokemon_potion.svg",
"name": "Awesome Plastic Pizza",
"price": 27,
"pokemonId": 1
},
// ...
]
This route updates the item matching the id in the route parameter.
The payload that you must send looks like this.
{
"id": 1,
"happiness": 86,
"imageUrl": "/images/pokemon_potion.svg",
"name": "Awesome Plastic Pizza",
"price": 27,
"pokemonId": 1
}
Successful response is the updated item returned and looks like this:
{
"id": 1,
"happiness": 86,
"imageUrl": "/images/pokemon_potion.svg",
"name": "Awesome Plastic Pizza",
"price": 27,
}