Skip to content

Latest commit

 

History

History
107 lines (72 loc) · 2.68 KB

setup.md

File metadata and controls

107 lines (72 loc) · 2.68 KB

React Seed - Setup

Install dependencies

Restore all packages from root folder:

$ yarn  # yarn install

Database

You can install Postgres or run your server in a Docker container.

Postgres

  • Install postgres. When prompted to enter the postgres user password, use sa.pg.01 or one of your choice
    • Make sure to update the password in server/datastore/create/knexfile.js if you picked a different password.
  • For more information about setting up the server see official docs

Docker

  • Install Docker and docker-compose
  • Run yarn database:docker-server to create the docker container for the Postgres Server (volume to persist data will be mounted)

Structure and Data

Once you have configured your Postgres server, run the following commands:

  • Create the reactseeddb database, pg user and grant access to database:
    • yarn database:create
  • Create tables running migrations:
    • yarn migrate:latest
  • Populate database running the seeds:
    • yarn seed:run

Start the app

Execute the express server

Development (with nodemon)

$ yarn dev # or (yarn run dev)

Production

$ yarn prod # build and start

Open browser on localhost:4000

NPM Scripts

$ yarn build # build production assets

$ yarn start # execute production server

$ yarn test # execute all tests

$ yarn lint # execute linting

More scripts

  • test: exec all test (client uses jest, server uses tape)
    • test:client: exec client test
    • test:server: exec server test
  • tdd: exec test (on watch mode)
  • lint: exec linting (eslint)
  • migrate:*: knex migrations
    • migrate:make: create migration script
    • migrate:latest: exec migrations
    • migrate:rollback: rollback migration
  • seed:*: data seeds
    • seed:make: create seed script
    • seed:run: exec seeds
  • stats: run npm stats
  • build: build production assets
  • start: exec production server
  • dev: exec development server
  • prod: build production assets and exec production server

Development

Git Hooks (using husky)

In develop we use git hooks for automate linting and testing.

Using husky with yarn:

$ yarn add husky --dev --force  # ensures hooks will be installed

Install hooks manually (using node):

$ node node_modules/husky/bin/install