An API for studying terms, topics, and questions
Authentication is only required for write actions.
POST requests require Authorization: Bearer github_access_token
GET /auth/login
POST /auth/token requires code in body
GET /auth/validate Requires Authorization: Bearer github_access_token
Create an .env file with the following info:
DATABASE_URL=postgres://postgres:@localhost:5432/studybook
# For `npm run backup` command
PRODUCTION_DATABASE_URL=postgres://.../studybook?ssl=true
PRODUCTION_DATABASE_CA=xxxOPTIONALxxx
# for `npm run backup-db` command
DB_HOST=
DB_PORT=5432
DB_DATABASE=postgres
DB_USER=postgres
DB_PASSWORD=
# Auth support
GITHUB_CLIENT_ID=xxx
GITHUB_CLIENT_SECRET=xxx
Then one time install commands:
npm installcreatedb studybooknpm run migrate:devnpm run seed:dev
For support Auth, add the GITHUB_* keys from a Github App.
The Github App will need read:org scope.
nodemonnpm start
Runs on http://localhost:3001
Setup your local .env file with the PRODUCTION_DATABASE_URL from your Postgres, then run:
npm run migrate:production
npm run seed:production
This app is hosted on Render.com at studybook-api.vercel.app/. It will auto-deploy with commits push to main github repo.
A backup will save all tables from the production environment
npm run backup
Files output to backups/*.json