Skip to content

dangerdak/chrappjs

Repository files navigation

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: 'my@email.com', 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

About

Chr(istmas) App: A secret santa app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published