- Install dependencies
npm install
- Create OAuth credentials for GitHub
- Copy
.env-fileMake sure to generate the app secret and fill out your newly generated OAuth credentials.cp .env.example .env
openssl rand -hex 32
- If you already have MySQL running using systemd, stop it:
systemctl stop mysql.service
- Start MySQL and Redis (for persistent login sessions)
docker-compose up -d
- Migrate the database. Note that MySQL can take a few seconds to start.
npx prisma migrate dev
- Start the application
npm run dev
The API requires a few environment variables to run properly. A dotenv-file is used to quickly set environment variables. Start by copying the example envfile:
cp .env.example .envWhen copied, use the command openssl rand -hex 32 to generate a value for APP_SECRET. Then come back here and follow the remaining steps.
To be able to autheticate against GitHub you'll need to generate a secret pair. You should follow this guide using the information below:
| Field | Value |
|---|---|
| Application name | Anything you like, I used BTH pattern Group 14 local |
| Homepage URL | http://localhost:4000 |
| Application description | Anything you like, can be left empty |
| Authorization callback URL | http://localhost:4000/auth/github/callback |
When done, fill out GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET.
Stripe is not necessary to run the application, but it is to be able to test the billing functionality. It requires a few extra environment variables and optionally a webhook client.
First you must configure your Stripe credentials. This lets the application create payments and invoices.
- You need a account with Stripe. If you don't already, create one here: https://dashboard.stripe.com/register
- When you've created your account you need to set a company name to be able to
send invocies. When logged in to the dashboard
(https://dashboard.stripe.com/), click the name in the top left and then
"Edit" as shown in the screenshot. Then enter a suitable name.

- Make sure "Test mode" is enabled, then go to "Developers" and finally "API keys".

- Copy your "Publishable key" and "Secret key" and set them in your .env-file
STRIPE_SECRET_KEY="sk_test_xxx" STRIPE_PUBLISHABLE_KEY="pk_test_yyy"
Webhooks allow the application to know when a payment is completed. It can be left out, in which case the user has to click the "Pay now" button again after a payment is completed.
- Install the Stripe CLI utillity. https://stripe.com/docs/stripe-cli#install
- Before starting the API/backend, run the following command. This will allow
Stripe to call your application:
stripe listen --forward-to localhost:4000/payments/stripe/webhook
- Copy the printed signing secret to your .env-file. It should start with
whsec_.STRIPE_WEBHOOK_SECRET="whsec_zzz"
- Now you can start the API/backend. The webhook secret is usually the same between runs.
