This is a full-stack JavaScript app for a voting bracket on the best of the best dogs of 2020 from @dog_rates.
You'll need npm and node installed.
For npm dependencies, this will install all for the frontend and backend folders:
./scripts/install-all.sh
If not already installed, install postgres.
Make sure you have psql
installed as well, and that postgres is running on port 5432.
Your postgres user should have no password.
Create postgres local DB:
psql -c 'create database dograteslocal;' -U postgres
Run local database migrations:
./scripts/db-migrate.sh
This app needs tweet data from @dog_rates to work. To do this, there are two options. Self-populate your data, or use fixture data (contains only 2 months of tweets).
To self-populate your database, you need a Twitter OAuth 2.0 Bearer Token. You can follow
Twitter's instructions to create a developer
app and obtain a token. Save this to your environment as TWITTER_TOKEN
.
If you are using fixture data, do not set this environment variable at all.
Next, for either datasource, start the backend app locally and post to the /populate
endpoint.
npm --prefix=backend run start:dev -- &
curl -X POST localhost:8080/populate
kill $(lsof -i:8080 -t)
This will populate the tweets
table and its corresponding images
table.
Start frontend dev server:
./scripts/frontend-start.sh
Start backend dev server:
./scripts/backend-start.sh
The backend will run on port 8080 and the frontend will run on port 3000.
Run all jest tests:
./scripts/test-all.sh
In addition to tests, this script will run linting (via eslint) and dependency boundary checks (via good-fences)
Run cypress feature tests:
./scripts/feature-tests.sh
This will start and stop the server for itself, including a Wiremock server to provide stub versions of API dependencies.
npm --prefix=backend run db-migrate create [migration-name] -- --sql-file
Always push via ship-it (why?)
./scripts/ship-it.sh
Build frontend, build backend, compile all into one directory:
./scripts/build.sh
Start the production server (frontend & backend)
./scripts/prod-start.sh