Skip to content

Instantly share code, notes, and snippets.

@psychicbologna
Created October 10, 2019 21:33
Show Gist options
  • Save psychicbologna/b525099523bea7752ed0a0c15ef9e61c to your computer and use it in GitHub Desktop.
Save psychicbologna/b525099523bea7752ed0a0c15ef9e61c to your computer and use it in GitHub Desktop.

Notes

Client

Client Dependencies & devDependencies

  • jwt-decode What is this?
  • date-fns I remember you.
  • react-scripts What is this? It seems to be used in 'scripts' to streamline starting up a react project:
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  • What are the public and private route utilities? It looks like a layer over a component that decides whether or not they are accessible via token in one, and the exact opposite for the other.

  • what is utils.js? Is this really breaking down each element functionally? This is insane.

  • An implementation of star rating I probably won't steal. Seems to read the rating and then fill the stars based on that when loading.

  • Thingcontext and thinglistcontext - seem to contain functions that help manipulate the things in different contexts statefully.

-5 routes corresponding to CRUD endpoints. NotFound covers 'everything else?'

Server

env

  • process.env.TZ = 'UTC' Why is this set this way?

Server Dependencies & devDependencies

  • What is treeize? "Converts tabular row data (as from SQL joins, flat JSON, etc) to deep object graphs based on simple column naming conventions - without the use of an ORM or models." Remaps flat data into tree structure - deep object graphs, API-ready data.

  • Used in things-service.js to 'treeize' the reviewdata. Declare a treeize-class variable, then use it to 'grow' input data (must be an array) into a tree structure.

  • What is const reviewData = reviewTree.grow([ review ]).getData()[0] doing? Something with reorganizing the flat input from a review during serializeReview() in things-service.js so it's 'api ready'

  • "private":true ?

seed.thingful_tables.sql

  • The data structure is declared in INSERT w/o a TYPE?
  • Rating?

trunc.thingful_tables.sql

  • This seems to truncate the table in order; acts as 'unseeder'. Why is this separate from migrations? Will we be able to call this in other places like a func? Good for cleaning db, maybe using different seeds.

script: psql -U thingful -d thingful -f ./seeds/thingful_tables.sql

Data Design & Migrations

thingful-things <-> thingful_users <<-> thingful_reviews

"What is PostgreSQL SERIAL PRIMARY KEY?" -speedier syntax for incrementing key, good for primary id.

reviews-service.js

  • Uses raw data to select instead of knex methods.

things-router.js

  • What is async and await? How do they work?

    An async function 'always' explicitly returns a promise; an await, which 'must' be in an async function. It 'awaits' the result of a promise before executing. This would be good for asynchronous content, such as wait screens, and handling feedback for calls where you are uncertain of the outcome.

    It is essentially a cleaner syntax for a promise chain, less of an eyesore than a then chain.

So Async checkThingExists() - the function is out of sequence; it listens for 'thing', a constant that awaits the thing being checked for in the db, and produces feedback when it is discovered.

  • What is Restart Identity Cascade?

  • RESTART IDENTITY

    Automatically restart sequences owned by columns of the truncated table(s).

  • CASCADE

    Automatically truncate all tables that have foreign-key references to any of the named tables, or to any tables added to the group due to CASCADE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment