From root:
- Create local postgres database, set name to be
connections_testand port to5432(the default). CREATE DATABASE connections_test;pnpm install
Frontend:
cd apps/frontend- Copy over .env.example into .env and update vars
- Set
NEXT_PUBLIC_API_URLto point to the backend, defaults tohttp://localhost:8080/api
- Set
source .envpnpm run dev
Backend:
- In a separate terminal,
cd apps/backend - Copy over .env.example into .env and update vars
- Set
FRONTEND_URLto point to the frontend (for cors), defaults tohttp://localhost:3000 - Set
DATABASE_URLto point to the database, for local dev this defaults topostgresql://postgres:postgres@localhost:5432/connections_test?schema=public - Set
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION,AWS_SES_SENDER_EMAILto correspond to IAM credentials for AWS Simple Email Service
- Set
source .env- Run
pnpm prisma migrate devto run db migrations - Run
pnpm prisma generateto generate the prisma client pnpm run dev
Telegram:
- Create a bot on Telegram using BotFather (https://t.me/BotFather) to test with
- In
apps/backend/.env:- Set
TELEGRAM_BOT_APIto the bot api key - Set
TELEGRAM_BOT_USERNAMEto be the bot username - Set
TELEGRAM_BOT_START_DELAY_MSto the delay in ms before starting the bot, defaults to 0, mostly relevant in prod
- Set
Testing:
- This is meant to be a mobile browser app. You can either test this on mobile browser by connecting it to localhost or using ngrok/similar service, or test from a desktop web browser using mobile view
- This app does not work in incognito mode
- Make sure you've seeded database with testing UserChip values:
pnpm run seed- To register, visit: http://localhost:3000/tap?chipId=TEST001 and go through registration flow.
TEST002-TEST005are also available for testing.
- To register, visit: http://localhost:3000/tap?chipId=TEST001 and go through registration flow.
- Once logged in, to tap another account there are two steps:
- Create new account, visit http://localhost:3000/tap?chipId=TEST002 in a different browser
- To tap a connection, visit http://localhost:3000/tap?chipId=TEST002 from your first browser, where the chipId corresponds to the other existing account
- After a full deletion sometimes old local storage values will still be populating site, visit http://localhost:3000/logout to logout or delete the local storage corresponding to localhost:3000.
- To clear the database, run
pnpm prisma migrate resetfrom apps/backend. NOTE THIS WILL WIPE YOUR POSTGRES - To add fake leaderboard entries, in
apps/backendrunts-node -r tsconfig-paths/register prisma/testing/leaderboardEntries.ts.
Testing Secret Values:
- For the email service,
AWS_SES_SENDER_EMAIL,AWS_ACCESS_KEY_ID,AWS_REGION, andAWS_SECRET_ACCESS_KEYmust be set with target email and key info.
Testing Utilities:
- For accessing local DB:
psql postgresql://postgres:postgres@localhost:5432/connections_test - For dropping test DB:
psql,DROP DATABASE connections_test WITH (FORCE); \lto list dbs,\c $dbnameto connect,\dto list tables.- To filter requests in Chrome Inspect, use negative filter
-.png -.jpg -.jpeg -.gif -.json -.jsin Network tab. - After a full deletion sometimes an old cookie will still be populating site, to delete in Chrome:
Settings->Privacy and security->Third-party cookies->See all site data and permissions-> search for localhost -> delete cookies
Notes:
- API/backend uses null types for interop, client storage uses undefined for storage efficiency - conversions are done with zod.transform