Build a web app that fits in a 3 KB data: URI, get cool prizes!
Requires Node 20+ and PostgreSQL.
npm install
cp .env.example .env.local # set DATABASE_URL and ENCRYPTION_KEY
createdb shrink
npm run db:migrate
npm run devWith HCA_CLIENT_ID unset, next dev runs in staging mode: /login signs
you in as a local account (role from STAGING_ROLE, default admin),
Hackatime returns fixed projects, and orders use a fake address. Production
builds never enable staging.
| Script | |
|---|---|
npm run dev |
dev server |
npm run build |
apply migrations, then next build |
npm run db:generate |
generate a migration from lib/server/db/schema.ts |
npm run db:migrate |
apply migrations in ./drizzle |
npm run typecheck |
tsc --noEmit |
-
Create a Postgres database and set
DATABASE_URLto its pooled connection string. -
Set
ENCRYPTION_KEY(openssl rand -hex 32) andADMIN_EMAILS. -
Register an app with Hack Club Auth using redirect URI
https://<host>/api/auth/callbackand setHCA_CLIENT_ID/HCA_CLIENT_SECRET. -
Register an OAuth app with Hackatime using redirect URI
https://<host>/api/auth/hackatime/callbackand setHACKATIME_CLIENT_ID/HACKATIME_CLIENT_SECRET. -
Optionally set Slack, Airtable,
GITHUB_TOKENandOPENROUTER_API_KEY(see.env.example). -
For Airtable, set
AIRTABLE_API_KEY,AIRTABLE_BASE_ID,APP_URLandCRON_SECRET.vercel.jsonrunsGET /api/cron/airtablehourly; Vercel sendsAuthorization: Bearer $CRON_SECRETitself. Users, Ships and Orders are mirrored on every change and on each run; approved ships are filed once to YSWS Project Submission. Admins can also resync from/admin. -
For the Slack "join" button, set
SLACK_JOIN_SECRETand point the webhook atPOST https://<host>/api/slack/joinwithAuthorization: Bearer <secret>(or?secret=) and the Slack ID asslack_id, in a JSON or form body or the query string. It creates the user and mirrors them to Airtable; signing in later claims that row, and they still go through/welcome. Give the botusers:readandusers:read.emailso the row gets their Slack name and email.
The build runs migrations against DATABASE_URL before next build.