diff --git a/.env.example b/.env.example index 0d6c6b6..c975f4f 100644 --- a/.env.example +++ b/.env.example @@ -6,15 +6,15 @@ PORT=4000 # 32+ random chars: openssl rand -hex 32 JWT_SECRET=change-me-change-me-change-me-change-me # Comma-separated. Anyone else who logs in is an ATTENDEE. -ADMIN_EMAILS=tech@ethiopiatrustfund.org +ADMIN_EMAILS=admin@example.com STAFF_EMAILS= # Browser origins allowed to call the API (site, admin). The mobile app needs none. CORS_ORIGINS=http://localhost:3000,http://localhost:5173 -SITE_URL=https://grv.ethiopiatrustfund.org +SITE_URL=http://localhost:3000 ADMIN_URL=http://localhost:5173 # Empty RESEND_API_KEY = emails (and OTP codes) are printed to the console instead of sent. RESEND_API_KEY= -RESEND_FROM=GRV Summit -NOTIFY_TO=tech@ethiopiatrustfund.org +RESEND_FROM=GRV Summit +NOTIFY_TO=admin@example.com # Shown to buyers after a ticket order until a payment gateway is wired. PAYMENT_INSTRUCTIONS=Our team will email you an invoice with bank transfer details within one business day. Your tickets are issued once payment is confirmed. diff --git a/API.md b/API.md index 4345ab3..fbb8535 100644 --- a/API.md +++ b/API.md @@ -9,7 +9,7 @@ JSON in and out. Money is integer minor units (cents) with a `currency` (`"USD"` (`ADMIN_EMAILS` / `STAFF_EMAILS` env allowlists, otherwise `ATTENDEE`). In dev the OTP is printed to the backend console. There is no refresh token: attendee tokens last 30 days, staff/admin tokens 12 hours. On 401, log out and ask for a new code. -QR codes encode a URL: checkpoints `https://grv.ethiopiatrustfund.org/q/`, tickets `.../t/`. +QR codes encode a URL: checkpoints `/q/`, tickets `/t/`. `POST /scan` accepts either the full URL or the bare token. ## Shared shapes diff --git a/README.md b/README.md index 8a3c75e..1fff161 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ pnpm install --frozen-lockfile && pnpm build && pnpm db:migrate && pnpm db:seed pm2 start dist/src/main.js --name grv-backend # NODE_ENV=production, env from .env ``` -Put it behind HTTPS (e.g. `api.grv.ethiopiatrustfund.org`). Set `CORS_ORIGINS` to the site and admin origins and `ADMIN_URL` to the admin's URL (used in staff emails). +Put it behind HTTPS. Set `CORS_ORIGINS` to the site and admin origins and `ADMIN_URL` to the admin's URL (used in staff emails). ## Not built yet diff --git a/src/common/env.ts b/src/common/env.ts index 181dd1c..41b3753 100644 --- a/src/common/env.ts +++ b/src/common/env.ts @@ -3,7 +3,7 @@ import 'dotenv/config'; const list = (v: string | undefined) => (v ?? '').split(',').map((s) => s.trim().toLowerCase()).filter(Boolean); -export const SITE_URL = (process.env.SITE_URL || 'https://grv.ethiopiatrustfund.org').replace(/\/$/, ''); +export const SITE_URL = (process.env.SITE_URL || 'http://localhost:3000').replace(/\/$/, ''); export const ADMIN_URL = (process.env.ADMIN_URL || 'http://localhost:5173').replace(/\/$/, ''); export const env = { diff --git a/src/common/mail.ts b/src/common/mail.ts index bc59f7d..df5a3c6 100644 --- a/src/common/mail.ts +++ b/src/common/mail.ts @@ -21,7 +21,7 @@ export async function sendMail(mail: Mail) { method: 'POST', headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ - from: process.env.RESEND_FROM || 'GRV Summit ', + from: process.env.RESEND_FROM || 'GRV Summit ', to: mail.to, subject: mail.subject, html: mail.html, @@ -34,7 +34,7 @@ export async function sendMail(mail: Mail) { return json.id; } -export const staffInbox = () => process.env.NOTIFY_TO || 'tech@ethiopiatrustfund.org'; +export const staffInbox = () => process.env.NOTIFY_TO || (process.env.ADMIN_EMAILS ?? '').split(',')[0].trim(); /** Fire-and-forget for flows whose data is already saved: failures are logged, never thrown. */ export function sendInBackground(label: string, mails: Mail[]) { diff --git a/test/core.test.ts b/test/core.test.ts index d5b35cf..dd0c212 100644 --- a/test/core.test.ts +++ b/test/core.test.ts @@ -78,7 +78,7 @@ describe('scans', () => { const booth = await prisma.checkpoint.create({ data: { kind: 'BOOTH', label: 'B', points: 10, qrToken: 'booth1' } }); await prisma.checkpoint.create({ data: { kind: 'MYSTERY_INVESTEE', label: 'M', points: 50, qrToken: 'myst1' } }); - expect((await game.scan(user, `https://grv.ethiopiatrustfund.org/q/${booth.qrToken}`)).total).toBe(10); + expect((await game.scan(user, `http://localhost:3000/q/${booth.qrToken}`)).total).toBe(10); await expect(game.scan(user, 'booth1')).rejects.toMatchObject({ status: 409 }); const mystery = await game.scan(user, 'myst1'); expect(mystery).toMatchObject({ pointsAwarded: 100, total: 110, mystery: true });