/dice-roller

RPG dice roller & template react/node/typescript app

Primary LanguageTypeScript

Dice Roller

An Express/React/typescript bootstrapper app

Getting Started

This typescript repo is structured with two primary sub-folders:

  • backend - the express API server
  • frontend - the react web UI

npm Dependencies

For npm dependencies:

./scripts/install-all.sh

postgres

If not already installed, install postgres

Create postgres local DB:

psql -c 'create database dicelocal;' -U postgres

Run database migrations:

./scripts/db-migrate.sh

Development

Start frontend dev server:

./scripts/frontend-start.sh

Start backend dev server:

./scripts/backend-start.sh

Run all jest tests, and linting:

./scripts/test-all.sh

Run cypress feature tests:

./scripts/feature-tests.sh

Fences

This repo uses good-fences to enforce module boundaries. Most importantly, the backend and frontend cannot import from each other.

Additionally, fences are used in the backend subdirectories to enforce dependency inversion. The routes and database folders depend on the interfaces defined in domain (only - not on each other), and domain is not allowed to import from any of these implementation directories.

Fences are enforced via a linting-like command that will fail when any violations are flagged:

npm --prefix=backend run fences
npm --prefix=frontend run fences

Adding DB migrations

npm --prefix=backend run db-migrate create [migration-name] -- --sql-file

Pushing changes

Always push via ship-it (why?)

./scripts/ship-it.sh

CI/CD

We use circleci.

The pipeline is:

  1. npm install (frontend and backend)
  2. run all unit tests (frontend and backend)
  3. build code and run feature tests
  4. deploy to GCP environment

Deployment

Build frontend, build backend, compile all into one directory:

./scripts/build.sh

Start the production server (frontend & backend)

./scripts/prod-start.sh

Deploying to GCP

First, make sure that Google Cloud SDK is installed

Ensure you are logged in to the CLI and pointing to the correct project.

This script generates the app.yaml and deploys the app:

./scripts/deploy.sh

Generally, developers won't have to do this - we have automated deploys via CircleCI.