# Sequelize Demo Feature Set
## Feature: 404 Page Not Found
**Scenario**: Katie happened to mistype the URL and pressed enter to issue a request to a route that does not exist on our server
Using the `404.js` file, create a middleware that will handle requests to pages/paths that don't exist and send Katie a nice image
## Feature: 500; We Messed Up
**Scenario**: Josh requests a page that does exist. However, we didn't catch a typo in our route when trying to request data
Using the `500.js` file, create a middleware that will send Josh a nice image when we mess up on our server
## Feature: Creating Associations
**Scenario**: Think about Pokémon like animals with super powers and they also have trainers. We need to create associations amongst our tables. Create Model Associations based on below criteria
* Each Pokémon has at least one type, at most, two
* Each Pokémon has at most, one Trainer
* A Trainer can have multiple Pokémon
Bonus Feature: ~~Redacted~~
## Feature: Using Magic Methods in `seed.js`
**Scenario**: We (the development team) need dummy data and we already have some. However, since we have set up our associations and seeded our current data, the foreign keys created by the associations in the tables are `NULL`. Using magic methods:
* Set Garchomp's Trainer to Katie
* Set Lucario's Trainer to Finn
* Set Sylveon's Trainer to Ben
* Set Flygon's Trainer to Jess
* Set Garchomp's Types to Dragon and Flying
* Set Lucario's Types to Fighting and Steel
* Set Sylveon's Type to Fairy
* Set Flygon's Types to Dragon and Ground
## Feature: Get All Pokémon
**Scenario:** Timmy wants to be able to see all the Pokémon available
Write a route that displays all the Pokémon in our database when the URL maches: `localhost:1340/pokemon`. Test with an API client.
## Feature: Get a Single Pokémon
**Scenario**: Vikki wants to be able to see a specific Pokémon
Write a route that displays a single Pokémon when the URL matches: `localhost:1340/pokemon/:id`. Test with an API client.
## Feature: (Eager) Loading Need More Data
**Scenario**: Timmy from earlier wants to be able to see all the Pokémon available in addition to their possible Trainer data
Modify the `GET /pokemon` route, specifically, the Sequelize method such that we are able to get Trainer data in additional to Pokémon Data *without* having to do separate Sequelize method calls to the database. Test with an API client.
## Feature(s): (Class Methods) Finding the Pokémon with the Highest HPs
**Scenario**: Andrea wants to be able to see all the Pokémon with HPs higher than 800
* **[Sequelize]** Write a class method called `findHighHp` for the Pokémon model that queries the database to find all the Pokémon with HPs higher than 800
* **[Express]** Write a route that displays the Pokémon with the highest HP when the URL matches `localhost:1340/pokemon/hp`. Test with an API client.
## Feature(s): (Instance Methods) Set the Trainer for a Potential New Pokémon Submission
**Scenario**: At some point in the future, we may need to create new Pokémon instances in our database via a form or otherwise
Write an instance method called `assignTrainer` on the Pokémon model that sets the Trainer of a new Pokémon submitted
## Big Feature: Adding a New Pokémon
**Scenario**: Jean wants to be able to submit a Pokémon to our database. The submission will include the name of the Pokémon, the types, the HP, the special attack, and the trainer name. We need to be able to set all the data correctly (i.e., the Pokémon's trainer, which sits in another table)
* **[Express]**: Using the `addPokemon.js` file, create a route that displays this form when the URL matches: `localhost:1340/pokemon/add`
* **[Express]**: Create a POST route that takes the data submitted from the form that:
* Checks if the trainer submitted exists in our database. If so, return the trainer. If not, create the trainer, then return the newly created trainer
* Checks if the type 1 property submitted exists in our database. If so, return the type. If not, create the type, then return the newly created type
* Checks if the type 2 property submitted exists in our database. If so, return the type. If not, create the type, then return the newly created type
* Creates a Pokémon based on the name, special attack, and HP properties we received
* Uses the `assignTrainer` instance method on the Pokémon Model to set the Trainer that was submitted
* Uses the `setTypes` Magic Method to set the new Pokémon's types that were submitted
* Returns the newly created Pokémon back to the requestor
## Bonus Features
* **[Express `PUT` Request & Sequelize `update`]** Ahead of creating a frontend feature for it, we want to create a PUT route that edits a Pokémon's special attack in our database. We will test it using an API client
* **[Express `DELETE` Request & Sequelize `destroy`]** Ahead of creating a frontend feature for it, we want to create a DELETE route that deletes a specific Pokémon from our database
* **[Sequelize]** Create a New Model called Team, that has one property, name, and it's a string and also create associations for it (Trainer belongs to team and Team has many trainers)
* **[Sequelize]** Create seed data for it (Team Mystic, Team Instinct, Team Valor)
* **[Sequelize]** Create an `afterCreate` Hook such that if the teamId is null on a Trainer, assign them a default team
* **[Express + Sequelize]** Ahead of creating a frontend feature for it, we want to create a route that handles "search" for us. We specifically want to search if there is a Pokémon that uses the specified special attack in the search. We will test this on Insomnia.
* If the Pokémon exists, send a status 302 (found) along with the Pokémon that was found
* If the Pokémon doesn't exist, send a status 404 (not found) along with a message saying it was not found
* Bonus: Construct a frontend to handle this