FIND any Pokémon. Find your favorite Pokémon right away through our extensive directory. LEARN about your Pokémon. Uncover everything you need to know about any Pokemon, including their HP, strengths, weaknesses, special defenses, and more! TRACK and grow your Pokémon Build your very own powerful team of Pokémon. You can build and customize as many teams as you want.
This repository holds all back-end files and resources for pokestats application and its readme documentation. This repository was made during Lambda School's build week where students join a team that consists other students from different cohorts. Each cohorts are responsible for either UI, Front End, Back End, and leading the team. This repository is for th Back end side.
https://pokepokepokedex.herokuapp.com
Fork/Clone the repository. In the same directory as the package.json, in your terminal:
yarn install
This is to install all needed packages. To start the server, in your terminal, type:
yarn server
To test the repository:
yarn test
Found in: https://www.kaggle.com/rounakbanik/pokemon
users
{
"id": 1, // Integer [Primary key]
"username": "admin", // String [Required, Unique]
"password": "password", // String [Required]
"email": "[email protected]" // String [Required, Unique]
}
pokemon
{
"id": 1, // Integer
"name": "Bulbasaur", // Text
"pokedex_number": 1, // Integer
"type1": "grass", // Text
"type2": "poison", // Text
"height_m": 0.7, // Numeric(3, 1)
"weight_kg": 6.9, // Numeric(4, 1)
"abilities": "['Overgrow', 'Chlorophyll']", // Text
"base_happiness": 70, // Integer
"hp": 45, // Integer
"attack": 49, // Integer
"defense": 49, // Integer
"sp_attack": 65, // Integer
"sp_defense": 65, // Integer
"speed": 45, // Integer
"generation": 1, // Integer
"capture_rate": "45" // Text
}
backpack
{
"id": 1, // Integer [Primary key]
"type1": fire, // String [Required]
"type2": flying // String
"name": Charizard // String [Required]
"pokedex_number": 9, // Integer [Required, Unsigned]
"users_id": 1 // Integer [Foreign Key]
}
navigate at the end of url by: ?page=2
{
"total": 1,
"last_page": 1,
"per_page": 15,
"current_page": 1,
"from": 0,
"to": 1,
"data": []
}
username: 'admin',
password: 'password'
username: 'beniscool',
password: 'password'
username: 'ceciljohn',
password: 'password'
name | method | endpoint | description |
---|---|---|---|
Register | POST | /auth/register | Creates a new user to the users table in the database |
Login | POST | /auth/login | Checks whether payload from the body matches with a user in the database. On Succesful login, returns a message and a JWT Token |
Get all users | GET | /api/users | PROTECTED ROUTE - Returns an array of user objects of all users |
Get user by ID | GET | /api/users/:id | PROTECTED ROUTE - Returns an array of object of selected user by ID |
Delete user by ID | DELETE | /api/users/:id | delete selected user by ID |
Get all pokemon | GET | /api/pokemon/all | PROTECTED ROUTE - Returns an array of pokemon objects of all pokemon(limited) |
Get all pokemon by pagination | GET | /api/pokemon | PROTECTED ROUTE - Returns an array of pokemon objects of all pokemon with pagination |
Get ErrThang | GET | /api/pokemon/errthang | PROTECTED ROUTE - Gets all pokemon with all properties without pagination |
Get pokemon by ID | GET | /api/pokemon/:id | PROTECTED ROUTE - Returns an array of pokemon objects of selected pokemon by ID |
Get backpack of specific user | GET | /api/backpack:id | PROTECTED ROUTE - Returns and array of objects of all pokemons in the user's backpack |
Get all pokemon | GET | /api/backpack | PROTECTED ROUTE - returns an array of pokemon in backpack object |
Insert to backpack | POST | /api/backpack | PROTECTED ROUTE - Inserts payload into the backpack database |
Delete in backpack | DELETE | /api/backpack/:id | PROTECTED ROUTE - Delete a specific pokemon in backpack |
Method Url: /auth/register
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
username |
String | Yes | Must be unique |
email |
String | Yes | Must be unique |
password |
String | Yes |
example:
{
username: "ceciljohn",
password: "password",
email: "[email protected]"
}
If you successfully register a user the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"message" : "You have registered, ceciljohn!"
}
If you send in invalid fields, the endpoint will return an HTTP response with a status code
400
and a body as below.
{
"error": true,
"message": "There was a problem with your request."
}
Method Url: /auth/login
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
username |
String | Yes | Must match a username in the database |
password |
String | Yes | Must match a password in the database corresponding to above email |
example:
{
username: "ceciljohn",
password: "password"
}
If you successfully login, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"message": "Welcome ceciljohn!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTQ0MzM1NjUxLCJleHAiOjE1NzU4OTMyNTF9.uqd2OHBYkGQpwjLTPPiPWYkYOKlG7whQDFkk46xGXoE"
}
If you send in invalid fields or the passwords do not match, the endpoint will return an HTTP response with a status code
400
and a body as below.
{
"error": true,
"message": "There was a problem with your request."
}
If you send in an email address that does not match one in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
{
"error": true,
"message": "The requested content does not exist."
}
Mehod Url: /api/users
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
If you successfully get al the users, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
{
"total": 3,
"last_page": 1,
"per_page": 15,
"current_page": 1,
"from": 0,
"to": 3,
"data": [
{
"id": 1,
"username": "admin",
"email": "[email protected]"
},
{
"id": 2,
"username": "beniscool",
"email": "[email protected]"
},
{
"id": 3,
"username": "ceciljohn",
"email": "[email protected]"
}
]
}
}
If you send in invalid fields or the password of the user corresponding to the token does not match the currentPassword field, the endpoint will return an HTTP response with a status code
400
and a body as below.
{
"error": true,
"message": "There was a problem with your request."
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/users/:id
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
name | type | required | description |
---|---|---|---|
id |
Int | Yes | Id of specific user |
If you successfully get al the users, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"id": 1,
"username": "admin",
"email": "[email protected]"
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/users/:id
HTTP method: [DELETE]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
id |
Int | Yes | Id of specific user |
If you successfully delete the selected user, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"id": 1,
"username": "admin",
"email": "[email protected]"
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
TBA
Mehod Url: /api/pokemon/all
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
If you successfully get all the pokemon, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
{
"id": 1,
"name": "Bulbasaur"
},
{
"id": 2,
"name": "Ivysaur"
},
{
"id": 3,
"name": "Venusaur"
},
{
"id": 4,
"name": "Charmander"
},
{
"id": 5,
"name": "Charmeleon"
},
...
to the 800th+ pokemon object
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/pokemon/errthang
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
If you successfully get all the pokemon, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"id": 1,
"name": "Bulbasaur",
"pokedex_number": 1,
"type1": "grass",
"type2": "poison",
"height_m": 0.7,
"weight_kg": 6.9,
"abilities": "['Overgrow', 'Chlorophyll']",
"base_happiness": 70,
"hp": 45,
"attack": 49,
"defense": 49,
"sp_attack": 65,
"sp_defense": 65,
"speed": 45,
"generation": 1,
"capture_rate": "45",
"graph": [
1,
1,
1,
0.5,
0.5,
0.5,
2,
2,
1,
0.25,
1,
2,
1,
1,
2,
1,
1,
0.5
]
},
{
"id": 2,
"name": "Ivysaur",
"pokedex_number": 2,
"type1": "grass",
"type2": "poison",
"height_m": 1,
"weight_kg": 13,
"abilities": "['Overgrow', 'Chlorophyll']",
"base_happiness": 70,
"hp": 60,
"attack": 62,
"defense": 63,
"sp_attack": 80,
"sp_defense": 80,
"speed": 60,
"generation": 1,
"capture_rate": "45",
"graph": [
1,
1,
1,
0.5,
0.5,
0.5,
2,
2,
1,
0.25,
1,
2,
1,
1,
2,
1,
1,
0.5
]
},
...
to the 800th+ pokemon object
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/pokemon
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
If you successfully get all the pokemon with pagination that limits the list to 15 pokemon per page, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"total": 801,
"last_page": 54,
"per_page": 15,
"current_page": 1,
"from": 0,
"to": 15,
"data": [
{
"id": 1,
"name": "Bulbasaur",
"pokedex_number": 1,
"type1": "grass",
"type2": "poison",
"height_m": 0.7,
"weight_kg": 6.9,
"abilities": "['Overgrow', 'Chlorophyll']",
"base_happiness": 70,
"hp": 45,
"attack": 49,
"defense": 49,
"sp_attack": 65,
"sp_defense": 65,
"speed": 45,
"generation": 1,
"capture_rate": "45"
},
...
{
"id": 15,
"name": "Beedrill",
"pokedex_number": 15,
"type1": "bug",
"type2": "poison",
"height_m": 1,
"weight_kg": 29.5,
"abilities": "['Swarm', 'Sniper']",
"base_happiness": 70,
"hp": 65,
"attack": 150,
"defense": 40,
"sp_attack": 15,
"sp_defense": 80,
"speed": 145,
"generation": 1,
"capture_rate": "45"
}
]
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/pokemon/:id
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
name | type | required | description |
---|---|---|---|
id |
Int | Yes | Id of specific pokemon |
If you successfully get the selected pokemon, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"id": 151,
"name": "Mew",
"pokedex_number": 151,
"type1": "psychic",
"type2": null,
"height_m": 0.4,
"weight_kg": 4,
"abilities": "['Synchronize']",
"base_happiness": 100,
"hp": 100,
"attack": 100,
"defense": 100,
"sp_attack": 100,
"sp_defense": 100,
"speed": 100,
"generation": 1,
"capture_rate": "45"
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/backpack
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
If you successfully get all the pokemon in the backpack table, the endpoint will return an HTTP response with a status code
200
and a body as below.
[
{
"id": 1,
"type1": "fire",
"type2": null,
"name": "Charmander",
"pokedex_number": 4,
"users_id": 1
},
{
"id": 2,
"type1": "water",
"type2": null,
"name": "Squirtle",
"pokedex_number": 7,
"users_id": 2
}
]
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/backpack
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
name |
String | Yes | |
pokedex_number |
Integer | Yes | |
type1 |
String | Yes | |
type2 |
String | No | |
users_id |
Interer | Yes | Foreign Key |
example:
{
"name": "Squirtle",
"pokedex_number": 7,
"type1": "water",
"type2": null
"users_id": 1,
}
If you successfully get all the pokemon in the backpack table, the endpoint will return an HTTP response with a status code
200
and a body as below.
{
"id": 3,
"type1": "water",
"type2": null,
"name": "Squirtle",
"pokedex_number": 7,
"users_id": 1
}
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/backpack/:id
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
name | type | required | description |
---|---|---|---|
id |
Int | Yes | Id of specific user |
If you successfully get al the users, the endpoint will return an HTTP response with a status code
200
and a body as below.
[
{
"id": 1,
"type1": "fire",
"type2": null,
"name": "Charmander",
"pokedex_number": 4,
"users_id": 1
},
{
"id": 2,
"type1": "water",
"type2": null,
"name": "Squirtle",
"pokedex_number": 7,
"users_id": 1
},
{
"id": 3,
"type1": "water",
"type2": null,
"name": "Squirtle",
"pokedex_number": 7,
"users_id": 1
}
]
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}
Mehod Url: /api/backpack/:id
HTTP method: [DELETE]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | No | Bearer JWT authorization token |
name | type | required | description |
---|---|---|---|
id |
Int | Yes | Id of specific user |
If you successfully delete one pokemon in backpack, the endpoint will return an HTTP response with a status code
200
and a body as below.
1
If you are not logged in, then endpoint will return an HTTP response with a status code
401
and a body as below.
{
"error": true,
"message": "You are unathorized to view the content."
}