Giter VIP home page Giter VIP logo

chrappjs's Introduction

Chrappy Build Statuscodecov

A Secret Santa App

Why

What

How

Stages of development

  1. Serve a few pages.
    Write tests for status code and title string for each
  2. Add users to database
    • Create database build files
    • Database queries (insert user, get user)
    • Also write tests for database queries
  3. Link login and registration pages to database
  4. Add groups to database
    • Display groups on groups page
    • Ability to create groups
    • " edit groups
    • Invite people

Running locally

Start both the node server and the react server:

npm run dev

Things I Learnt

  • travis 'install' stage is where npm install happens - so be careful if you override this in .travis.yml
  • To stop database connections from hanging, use pg pool's end method to close the connection see docs
    (there are restrictions on when you can do this - maybe not more than once for a given pool?)
  • To be able to run a module from the command line:
    if(require.main == module)
      yourFunction();
    
  • When using supertest for post requests, use the .send method to include form data, and .type('form') to populate req.body with that data (you also need to be using body-parser for this to work) e.g.:
    supertest(app)
      .post('/login')
      .type('form')
      .send({ email: '[email protected]', password: 'top secret' })
      .end(blah blah blah);
    
  • When hashing passwords, use the bcrypt module rather than inbuilt crypto. bcrypt is designed for hashing passwords and is more computationally expensive (harder to brute force), and a work factor can be provided so it can be made more expensive as computers get faster.
  • The jsonwebtoken module is synchronous under the hood, despite offering an async API #11

Resources

chrappjs's People

Contributors

dangerdak avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

chrappjs's Issues

Logout

Users should be able to logout

  • button only shows when logged in
  • deletes token from local storage

Group invitations

Add ability to invite people to a group, and to email and accept invitations

  • Add form with inputs for peoples emails #52
  • Email invites to people
  • Create table for invites? (from_id, to_email, group_id)? redis?
  • show list of invited people (and indicate if they've accepted yet)
  • Each group needs an admin (groups now have an owner)

Date validation incorrect

Currently date validation claims "Date must have format yyyy-mm-dd but you entered".

  • This is not the format the date is expected in
  • and what the user entered is not displayed

Database seed file

Should be able to reset database but also add in initial data for testing purposes

Create groups

  • Add groups table to db
  • Add page for creating a new group
  • Write insertGroup query which saves a new group to db
  • Write validator for group info
  • Write getGroups query which returns groups for a user id
  • Show groups a user belongs to

Proptype issue on login page

Warning: Failed prop type: The prop location.state is marked as required in Login, but its value is undefined.

When logged in and visiting without being redirected there.

Group detail

add group detail component showing

  • name, description, budget
  • members

homepage

The app should have a home page - this could be the groups page, or a user dashboard with groups and wishlists or something...

Html head

partials/htmlHead.hbs

  • should contain required settings for accessibility
  • responsiveness

Serve templates

Site should be able to serve some pages.
Start with:

  • /register
  • /login
  • /groups

Forgotten password

Users should be able to request to change their password if they've forgotten it

Duplicate queryfile

Shouldnt be creating the same queryfile object multiple times (in backend.test and database.test.

Instead create both within db_build.js and export two functions using each sql file:

const path = require('path');
const dbConnection = require('./db_connection');
const { QueryFile } = require('pg-promise');

const seedFile = new QueryFile(path.join(__dirname, 'db_seed.sql'), { minify: true });
const buildFile = new QueryFile(path.join(__dirname, 'db_build.sql'), { minify: true });

const build = queryFile => dbConnection.any(queryFile)
  .then(() => {
    console.log('Database build successful.');
  });

/* istanbul ignore if */
if (require.main === module) {
  let file;
  if (process.argv[2] === '--seed') {
    file = seedFile;
  } else {
    file = buildFile;
  }
  build(file)
    .catch(console.log);
}

module.exports = {
  build: build.bind(null, buildFile),
  seed: build.bind(null, seedFile),
};

Use react

Use react for the front end to get practice :)
pages to convert:

  • login
  • Register
  • View groups
  • authentication (using jwts, frontend)
  • create a group
  • test private routes

Editable groups

Groups should be editable by their owner once they've been created.

Include link from groups page to edit page for groups current user owns.

Use flash messages

Instead of adding error messages to the context object being sent to handlebars templates. This is more versatile and allows messages to be added on redirect. FAC-11/AllAboutMe#108

Invites - functionality

  • User submits invites form
  • Emails are validated client side
  • Emails are validated server side
  • Invitation token created for each invite - corresponding to group id and email
  • Emails sent
  • User follows link containing invitation token
  • Acess invites db table & users table, check if email is registered already
  • If existing user, asked to log in (if not already)
  • If new user, asked to register
  • On reg/login, user is added to the group
  • Invitation token deleted from db

Create users

  • create database
  • create users table
  • password hashing and validation
  • create session on login/register

Error messages

display message to user if there's been an error/invalid input

Invites - frontend

Should be able to:

  • add invitee
  • delete invitee
  • edit invitee? - not necessary
  • basic styling
  • validation

Set up eslint

Linting isn't currently set up, set up eslint with airbnb guide and remove linting issues it finds.

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.