Skip to content

fac-17/Week-6-BHKM-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Week-6&7-BHKM-

Database project

Andy, Christine, Emmanuel, Martha

Team BHKM - Bugbear

Project

  • This week's project will involve setting up a database which you connect to via a node.js server. You'll use your data to make a dynamic web app for your front-end.
  • Some suggested project ideas are below. Feel free to modify according to your interest, provided your idea has similar functionality.

Requirements

  • 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.

code of conduct

  • BEM
  • Ensure euqual number of commits
  • Commit often
  • Switch regularly but (do few commits first)
  • Compartmentalise and work on the dedicated branch (pushing only needed after milestones)
  • feature and fix branches

Idea

  • Users are able to search for peetpeeves, add comments or create new petpeeves that they have

  • You will need to make the requests and update the DOM in response using client-side JavaScript.

  • As well as serving static HTML and JS files, your server will also need to provide endpoints that return DB query results as JSON. You can query your server from the client using the XMLHttpRequest method.

  • You'll need to be able to make both POSTand GET requests to your server.

MVP

  • Mobile first design
  • Basic site with long list of previous inputs by user
  • Logo in top left, description and a search bar
  • Field inputs are category, name and rant

Stretch goals

  • Client-side and server-side validation on login form, including error handling that provides feedback to users
  • Add like functionality to content
  • Add comment functionality to content
  • Allow users to delete the content that they have submitted
  • Add roles and permissions - Have an "admin" level user (role) who can edit and delete all content 😱 (permissions)
  • Refactor xmlhttp to fetch and callbacks to promises
  • Email address for users

TO-DO

TO-DO / Process

Frontend

  • Setting up the HTML for the landing page
  • Putting in the log-in forms
  • Setting up the front-end validation

Backend

Database:

  • Create new database table for log-in info
  • New query
  • Backend validation via router and handler
Log in
  • Send username and password info to backend
  • Backend check to see if the two match
  • Sending sign up data to backend
  • Comparing user infor to databse checking if user existis
  • Hashing pasword
  • Sending error messages if user exists
Register
  • Post request from front end (form -> send to backend)
  • Backend Router -> Handler (use of similar functions to "postData" and "getData" from last week)
  • Update database
  • Hashing + salting pasword (Bcrypt module)

Code of Conduct

  • BEM
  • Ensure equal number of commits
  • Commit often
  • Switch regularly but (do few commits first)
  • Compartmentalise and work on the dedicated branch (pushing only needed after milestones)
  • Feature and fix branches

How to create local test database

  • pgcli (will get you into your 'username')

  • /d (gives you all tables currently accessible)

  • /l (gives you all local databases)

  • /c (lets you switch to a different database)

  • (once in the right database run) \i src/database/db_build.sql (the path starting at the root of your folder)

  • SELECT * FROM

  • go out of the pgcli and run: node <filebathtobuild.js> (node src/database/build.js = this will run the build file which will also build the remote database on heroku)

  • you can now outside of pgcli write: pgcli (selecting SELECT * from will populate the correct base)

Glossary

Hash - Server side - turns plain text password into hashed string of characters Link: https://github.com/foundersandcoders/ws-password-management

Salt - Random set of characters that generated by decrypt to make it difficult to decrupy usin ghte rainbow table Link: https://github.com/foundersandcoders/ws-password-management

Cookie - A cookie is a piece of data that your server, sends back to the browser, which the browser will then keep, and attach to every future request to that domain. Link: https://github.com/foundersandcoders/ws-cookies

Useful Tips

Add new table to database - node src.database/db_build.js SELECT * FROM *new added table