Skip to content

codefortulsa/courtbook

Repository files navigation

courtbook Build Status

A UI for manually providing data for courtbot.

Local development

  1. Create a Postgres database
  2. Copy .env.example to .env then change the example settings to your own.
    • DATABASE_URL setting is your Postgres connection URL which will be in this format: DATABASE_URL='postgres://USERNAME:PASSWORD@HOST:PORT/DATABASE'
    • DATABASE_DIALECT should be 'postgres'.
  3. Run app with npm run dev

Authentication (Optional)

By default, authentication is bypassed when developing locally. This is controlled by the environment variable BYPASS_AUTH. When this flag is not true, you will need to configure Auth0 and all of the AUTH0 environment variables.

Database migrations

Database migrations are handled on application startup by db-migrate.

Deploying to Heroku

  1. Follow the instructions below for configuring Auth0
  2. Create, configure, and push your Heroku app with the following:
heroku create
heroku addons:add heroku-postgresql
# See .env.sample for all possible env variables
heroku config:set ENV_VARIABLE=<value>
git push heroku master

Configuring authentication with Auth0

OAuth2 authentication is provided by Auth0 so these steps will get you going there:

  1. Register for an account with Auth0
  2. Create a new connection database for Courtbook
    • Name it "courtbook-user-database"
    • Disable sign ups - this prevents self-signup
  3. Create the "Courtbook UI" client - The client is used by the Courtbook UI for user authentication
    1. Click on "Clients" then the "Create Client" button.
    2. Fill in the client name as "Courtbook UI"
    3. Choose the "Single Page Web Applications" then click "Create"
    4. Under settings:
      1. Allowed origins (CORS):
      • Add https://<your_sub_domain>.herokuapp.com
      • Local development only add http://localhost:5000
      1. Allowed callback URLs:
      • Add https://<your_sub_domain>.herokuapp.com/login
        • Local development only add http://localhost:5000/login
  4. Create the "Courtbot" client - This client is used for courtbot to make calls to certain API endpoints without providing a username and password
    1. Click on "Clients" then the "Create Clients" button
    2. Fill in the client name as "Courtbot"
    3. Select "Non Interactive Clients" then click "Create"
  5. Create the "Courtbook API"
    1. Click on "APIs" then the Create API button and create the API with the following:
    2. Authorize the "Courtbook API" editing the API and clicking "Non Interactive Clients"