RESTful API for Sika Education activities. Deployed at https://activity-api.fly.dev.
- http://localhost:4000/docs: Development
- https://activity-api.fly.dev/docs: Production
POST /regenerate-posts
: RPC command to update the posts cache with latest data from the posts repo, authenticated with theWEBHOOK_TOKEN
environment variable.
Requires Docker.
git clone git@github.com:sikaeducation/activity-api.git
cd activity-api
npm install
cp .env.example .env # Fill out values
npm run dev
@/
is aliased ./src/
and $/
is aliased to ./test-helpers/
.
Install flyctl
to change deployment configuration.
- For development, copy
.env.example
to.env
and set values (see below for explanation) - For production, set these in GitHub secrets and variables:
- Secrets:
DATABASE_URL
: Full connection stringREPO_TOKEN
: To download data fromhttps://github.com/sikaeducation/posts
, generate on the personal access tokens pageWEBHOOK_TOKEN
: Allows the posts repo to make webhook requests to this app, generate on the Posts webhooks page.SENTRY_AUTH_TOKEN
: Upload token for source maps on build, generated with the Sentry wizard (npx @sentry/wizard@latest -i sourcemaps
)FLY_API_TOKEN
: For deploying to Fly, generate on the Fly personal access tokens page page
- Variables:
SENTRY_DSN
: Connection URL for Sentry, retrieve on the Sentry dashboardAUTH_KEY_URL
: JWKS well-known URLAUTH_AUDIENCE
: Authorized requesterPUBLIC_PORT
: External port to advertise (doesn't bind the port)PRIVATE_PORT
: Internal container port (must be 8080 for fly.io)
- Secrets:
GitHub actions needs its auto-generated GITHUB_TOKEN
to have permissions to create releases (repo
permissions). Set this under Workflow Permissions.
npm start
npm dev
npm run lint
npm run build
npm run build:docker
npm run test
,npm run test:watch
- Increment the version with
npm version { patch | minor | major }
and push. - App dashboard)