Skip to content

bmorganpa/DogWasteWatcher

Repository files navigation

Dog Waste Watcher

An app to track dog waste that is not picked up

Development

Database

  1. docker run --rm -d --name dogwastewatcher_development -v /srv/dogwastewatcher/development/db:/var/lib/postgresql/data -e POSTGRES_DB=dogwastewatcher_development -e POSTGRES_PASSWORD=password -p 55432:5432 postgis/postgis:11-2.5

Connect to the db with PGPASSWORD=password psql -h localhost -U postgres -p 55432 -d dogwastewatcher_development

Envrionment

Add the following to a `nextapp/.env' file (See nextapp/env.sample):

PGUSER=postgres
PGHOST=localhost
PGPASSWORD=password
PGDATABASE=dogwastewatcher_development
PGPORT=55432

AUTH0_DOMAIN=dogwastewatcher.auth0.com
AUTH0_CLIENT_ID=<INSERT_AUTH0_CLIENT_ID>
AUTH0_CLIENT_SECRET=<INSERT_AUTH0_CLIENT_SECRET>
SESSION_COOKIE_SECRET=<INSERT_SESSION_COOKIE>

REDIRECT_URI=http://localhost:3001/api/callback
POST_LOGOUT_REDIRECT_URI=http://localhost:3001/

MAPBOX_TOKEN=<INSERT_MAPBOX_TOKEN>

The SESSION_COOKIE_SECRET can be generated by running head -c24 /dev/urandom | base64

Running the app

  1. cd nextapp
  2. npm install
  3. npm run dev

Migrations

First setup an environment variable file with the following variables:

FLYWAY_URL=jdbc:postgresql://<host>:<port>/<database_name>
FLYWAY_USER=db_user
FLYWAY_PASSWORD=db_password
  1. Create new sql file under "migrations" directory
  2. docker run --rm --env-file <env_filename> --network="host" -v ${PWD}/migrations:/flyway/sql flyway/flyway:6.2.0 migrate

Integration tests

Start test database

  1. docker run --rm -d --name dogwastewatcher_test -v /srv/dogwastewatcher/test/db:/var/lib/postgresql/data -e POSTGRES_DB=dogwastewatcher_test -e POSTGRES_PASSWORD=password -p 55432:5432 postgis/postgis:11-2.5
  2. Run migrations on test db (See above)

Envrionment

Add the following to a `nextapp/.env.test' file (See nextapp/env.sample):

PGUSER=postgres
PGHOST=localhost
PGPASSWORD=password
PGDATABASE=dogwastewatcher_test
PGPORT=45432

Run tests

  1. cd nextapp
  2. npm install
  3. npm run integration-test