A simple multiplayer browser game inspired by Reddit's own Button, previously hosted at button.quest. When players press the button, they get points proportional to how long it's been since the button has been pressed.
The application is built on React and Express and uses WebSockets to provide realtime updates on other player's presses. Supabase provides easy access to a PostgreSQL database to store player data, with Fly.IO for easy deployment. While the frontend can be run independently, the backend expects it to be built and stored in a build/ folder that it can then serve from, and the frontend expects to be able to make API requests to the same server it's hosted from.
First, build the frontend:
cd frontendnpm installcd ../backendnpm run build:ui
Then, run the backend:
- Create the file
backend/.env(if it does not already exist) - Add the database's key as
SUPABASE_KEY=<key>to.env npm installnpm run start
To reload changes, re-run npm run build:ui and npm run start
- Install
flyctl:curl -L https://fly.io/install.sh | shand follow directions in the prompt - Build and deploy:
npm run deploy:full - Or, individually:
npm run build:uiand thennpm run deploy
Useful Fly.io commands:
- Connect to the deployed instance:
fly ssh console - Get the current database file:
fly sftp get ./data/db.json