GithubHelp home page GithubHelp logo

heroku-node-example's Introduction

Pokedex Express App (with models and users)

For this exercise, we will abstract SQL queries into model files to declutter our controller files - effectively moving completely into an MVC (model view controller) framework.

We will also be introducing a Users table so users can create accounts on the app.

Getting Started

  1. Fork and clone this repository to your computer
  2. Run yarn install to install dependencies
  3. Create a new Postgres database by running createdb pokemons -U <your_username>
  4. Run psql -U <your_username> -d pokemons -a -f tables.sql - this will create 2 new tables for you - a pokemons table and users table in the database
  5. Seed data into the newly created pokemons table by running psql -U <your_username> -d pokemons -a -f seed.sql (Note: this will run 3 INSERT queries to seed 3 pokemons into the table.)
  6. Look in the starter file called index.js, run nodemon to start local server on port 3000
  7. Open localhost:3000 on your browser and see the home page

Deliverables

  • Add in missing logic implementation in controllers/pokemon.js for updateForm and update
  • Add in missing logic implementation in controllers/user.js for login
  • Add a "Logout" button on home page that sends POST request to /users/logout to log out a user (hint: remember to remove cookies)
  • Ensure that you can create a new user account
  • Ensure that you can create a new pokemon

Further

Add the ability for users to own newly created pokemons.

  • Drop the database from earlier and implement a slightly different entity relationship - modify tables.sql to create a third table called user_pokemons that has a primary key id, and 2 foreign keys pokemon_id and user_id
  • Modify the pokemon/new.handlebars file to accept a new field called "user_id"
  • Modify the backend logic to assign any newly created pokemon to the specified user based on the value of the new user_id field
  • Update the user/user.handlebars file to show all pokemons that a specified user owns (eg. /users/1 should show the 1st user's account information and names of pokemons that she owns)

Notes

  • Singular vs plural naming is important. For this exercise, let's assume that the plural of pokemon is pokemons...
  • We have changed our table names to be plural. So user is now users table, and pokemon is now pokemons table.

heroku-node-example's People

Contributors

awongh avatar kach92 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.