Since the MCP authentication is having issues, here's the fastest way to get your game running:
-
Create App:
- Click "Create New App"
- Name: "Swap It Game"
- Click "Create"
-
Create Keyset:
- Click "Create New Keyset"
- Name: "Production"
- Click "Create"
-
Enable Features: Click on your keyset settings and enable:
Message Persistence:
- Toggle: ON
- Retention: 7 days
App Context (Objects):
- Toggle: ON
- Region: aws-iad-1 (or closest)
Click "Save Changes"
-
Copy Your Keys: From the keyset page, copy:
- Publish Key (pub-c-...)
- Subscribe Key (sub-c-...)
Run this in terminal:
cd /Users/craig/Documents/gits/swapit
cat > .env << 'EOF'
VITE_PUBNUB_PUBLISH_KEY=PASTE_YOUR_PUBLISH_KEY_HERE
VITE_PUBNUB_SUBSCRIBE_KEY=PASTE_YOUR_SUBSCRIBE_KEY_HERE
EOFReplace the placeholder values with your actual keys.
- In PubNub dashboard, go to Functions
- Click "Create New Module"
- Name: "Swap It Game Logic"
- Click "Create"
- Click "Create Function" → "Before Publish or Fire"
- Name: "Game Handler"
- Channel:
game.* - Open
server/before-publish-function.json your computer - Copy ALL the code
- Paste into PubNub function editor
- Click "Save"
- Click module settings (gear icon) → Enable "KV Store" → Save
- Click "Start Module"
- In your module, click "KV Store" tab
- Click "Add New Item"
- Key:
swapit:game:TESTGAME - Value:
{
"gameId": "TESTGAME",
"phase": "CREATED",
"players": ["player1", "player2"],
"winnerPlayerId": null,
"tiles": {},
"goalOrder": null,
"initialOrder": null,
"startTT": null,
"winTT": null
}- Click "Save"
npm run devOpen http://localhost:3000 in two browsers and test!
Note: For testing, use player IDs "player1" and "player2" to match the test game state.
That's it! Your game should be running.