- clone repo
- npm i
- add .env(SECRET=ahifusnf7jrs343) and config.env(DB_URL=postgres://sjbyaxhqxajulr:624aca55754a83fc5fe748e36c3d9e2a3eff2c2c3507e9bba3c596c991d0be20@ec2-54-247-82-14.eu-west-1.compute.amazonaws.com:5432/ddkg2afd14oh46 ) to root of folder
- nmp start and see site up and running on localhost:4444
- As a user I want to be able to visit the page without loggin-in.
- As a user I want to be able to log-in and see user info.
- As a user I want to be able to log-in and manipulate the table of characters.
- As a user I want to know that my user infor is secure.
- As a user I want to be able to log-out.
- Login form with 2 fields - username and password
- Users only have to log in once (i.e. implement a cookie-based session on login)
- Username is visible on each page of the site after logging in
- Any user-submitted content should be labelled with the authors username
- There should be protected routes and unprotected routes that depend on the user having a cookie or not (or what level of access they have).
- Website content should be stored in a database
- Include thorough tests on the back-end, testing pure functions and testing routes using Supertest. If you make external API calls, use Nock to mock the response for your tests.
- Test front-end logic, we don't expect tests on the DOM.
To maximise time in fulfiling the requirements (as part of our SGC from last week)
There should be protected routes and unprotected routes that depend on the user having a cookie or not (or what level of access they have).
Include thorough tests on the back-end, testing pure functions and testing routes using Supertest. If you make external API calls, use Nock to mock the response for your tests.
A Game of Thrones team builder
Learning Outcomes
High-level concepts
- What is a database, and when should you use one?
- What is a relational database?
- What is the difference between a SQL database and a NoSQL database?
- What is a database schema? How do you design one?
Implementation and deployment
- How to set up a local instance of Postgres.
- How to set up a remote instance of Postgres (e.g. ElephantSQL).
- How to connect Node to a Postgres instance using PG.
- How to avoid security vulnerabilities (e.g. script injections).
- How to use PSQL to work with Postgres from the command line.
Testing
- How to keep your tests consistent using a test database and build script
- How to write tests for database queries
- SQL skills
- Understanding the standard query structure.
- How to retrieve information from a database.
- How to update a database table by adding, deleting or changing data.
- How to sort and filter results.
- An understanding of table joins and how to use them.
- An awareness of subqueries.
- Discussed project ideas
- Decided on Game of Thrones database
- Mobbed software architecture, with config.env file, and installed our node packages as dependencies
- Mobbed the schema using diagramdb. Started with MANY tabhttps://i.imgur.com/s4mzF2F.jpgles to try and understand the different relationships (one-to-one, on-to-many, many-to-many) But this way unnecessarily complicated.
So we ended up with this...
- Created sql and js files in our database
- Modified sql info to better visualise clan builder
- On homepage user is presented with table of Game of Thrones characters listing their name, house and weapon.
- User is given instructions - select 3 characters to build their clan and survive Winter
- User selects three characters using checkboxes/ radio buttons next to each row
- User clicks submit button to lock-in their selection
- User is returned with a response saying whether they're alive or dead. eg “A Lannister repaid their debt by taking your life”
- Stretch - user inputs their name, if they survive a new table is shown of their team members