mirror of
https://github.com/DeNNiiInc/Connect-5.git
synced 2026-04-19 11:36:00 +00:00
Migrate from Supabase to direct PostgreSQL connection
- Replace @supabase/supabase-js with native pg library - Rewrite database.js to use PostgreSQL connection pool - Update server.js with PostgreSQL connection testing - Create postgres-schema.sql with complete database schema - Add apply-schema.js script for easy schema deployment - Update all documentation (README.md, DEPLOYMENT.md, deploy.sh) - Remove Supabase-specific files and references - Update db.config.example.js with PostgreSQL format
This commit is contained in:
44
README.md
44
README.md
@@ -10,7 +10,7 @@ A beautiful, feature-rich implementation of the classic Connect-5 (Gomoku) game
|
||||
|
||||
[](https://nodejs.org/)
|
||||
[](https://socket.io/)
|
||||
[](https://supabase.com/)
|
||||
[](https://postgresql.org/)
|
||||
[](LICENSE)
|
||||
|
||||
[Play Now](https://connect5.beyondcloud.technology/) • [Features](#features) • [Installation](#installation) • [Usage](#usage) • [Multiplayer](#multiplayer) • [Tech Stack](#tech-stack)
|
||||
@@ -70,7 +70,7 @@ A beautiful, feature-rich implementation of the classic Connect-5 (Gomoku) game
|
||||
|
||||
### Prerequisites
|
||||
- **Node.js** 18+ ([Download](https://nodejs.org/))
|
||||
- **Supabase Account** (Free tier available at [supabase.com](https://supabase.com/))
|
||||
- **PostgreSQL** Database ([Download](https://www.postgresql.org/download/))
|
||||
- **Git** ([Download](https://git-scm.com/))
|
||||
|
||||
### Quick Start
|
||||
@@ -84,12 +84,14 @@ cd Connect-5
|
||||
npm install
|
||||
|
||||
# Configure database
|
||||
# 1. Create a Supabase project at https://supabase.com
|
||||
# 1. Ensure PostgreSQL is running and create the database:
|
||||
# CREATE DATABASE connect5;
|
||||
# 2. Copy db.config.example.js to db.config.js
|
||||
cp db.config.example.js db.config.js
|
||||
|
||||
# 3. Edit db.config.js with your Supabase credentials
|
||||
# 4. Run the SQL schema in Supabase SQL Editor (see SUPABASE_SETUP.md)
|
||||
# 3. Edit db.config.js with your PostgreSQL credentials
|
||||
# 4. Run the SQL schema
|
||||
psql -h HOST -U postgres -d connect5 -f postgres-schema.sql
|
||||
|
||||
# Start the server
|
||||
npm start
|
||||
@@ -97,7 +99,7 @@ npm start
|
||||
|
||||
The server will start on **http://localhost:3000**
|
||||
|
||||
For detailed setup instructions, see [SUPABASE_SETUP.md](SUPABASE_SETUP.md)
|
||||
For detailed setup instructions, see [README_DB_CONFIG.md](README_DB_CONFIG.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -192,16 +194,16 @@ For detailed setup instructions, see [SUPABASE_SETUP.md](SUPABASE_SETUP.md)
|
||||
- **Supabase Client**: PostgreSQL database client with real-time capabilities
|
||||
|
||||
### Database
|
||||
- **Supabase**: Managed PostgreSQL database with real-time subscriptions
|
||||
- **Row Level Security**: Built-in security policies
|
||||
- **Auto-generated APIs**: RESTful and real-time APIs
|
||||
- **PostgreSQL**: Robust open-source relational database
|
||||
- **Connection Pooling**: Efficient connection management
|
||||
- **Native SQL**: Direct PostgreSQL queries for performance
|
||||
|
||||
### Dependencies
|
||||
```json
|
||||
{
|
||||
"express": "^4.18.2",
|
||||
"socket.io": "^4.6.1",
|
||||
"@supabase/supabase-js": "^2.39.0",
|
||||
"pg": "^8.11.3",
|
||||
"bad-words": "^3.0.4",
|
||||
"cors": "^2.8.5",
|
||||
"nodemon": "^2.0.22"
|
||||
@@ -221,7 +223,7 @@ Connect-5/
|
||||
├── 🌐 multiplayer.js # Multiplayer client logic
|
||||
├── 🖼️ Logo.png # BCT logo
|
||||
├── 🔧 server.js # Express & Socket.io server
|
||||
├── 💾 database.js # MySQL connection & queries
|
||||
├── 💾 database.js # PostgreSQL connection & queries
|
||||
├── 🎯 gameManager.js # Multiplayer game management
|
||||
├── 📦 package.json # Dependencies
|
||||
└── 📚 README.md # This file
|
||||
@@ -243,14 +245,16 @@ Edit `db.config.js`:
|
||||
|
||||
```javascript
|
||||
module.exports = {
|
||||
supabaseUrl: 'https://your-project.supabase.co',
|
||||
supabaseAnonKey: 'your-anon-key-here',
|
||||
supabasePassword: 'your-database-password',
|
||||
postgresConnectionString: 'postgresql://postgres:password@...'
|
||||
HOST: 'your-postgres-host',
|
||||
USER: 'postgres',
|
||||
PASSWORD: 'your-database-password',
|
||||
DB: 'connect5',
|
||||
dialect: 'postgres',
|
||||
pool: { max: 5, min: 0, acquire: 30000, idle: 10000 }
|
||||
};
|
||||
```
|
||||
|
||||
See [SUPABASE_SETUP.md](SUPABASE_SETUP.md) for detailed setup instructions.
|
||||
See [README_DB_CONFIG.md](README_DB_CONFIG.md) for detailed setup instructions.
|
||||
|
||||
### Server Configuration
|
||||
|
||||
@@ -272,7 +276,7 @@ sudo bash deploy.sh
|
||||
|
||||
The script will:
|
||||
- ✅ Prompt for project directory
|
||||
- ✅ Request Supabase credentials
|
||||
- ✅ Request PostgreSQL credentials
|
||||
- ✅ Configure database connection
|
||||
- ✅ Install dependencies
|
||||
- ✅ Detect and configure web server (Nginx/Apache)
|
||||
@@ -328,8 +332,8 @@ npm start
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Connection Refused Error
|
||||
**Problem**: Cannot connect to Supabase database
|
||||
**Solution**: Verify credentials in `db.config.js` and check Supabase dashboard
|
||||
**Problem**: Cannot connect to PostgreSQL database
|
||||
**Solution**: Verify credentials in `db.config.js` and check PostgreSQL is running
|
||||
|
||||
### Port Already in Use
|
||||
**Problem**: Port 3000 is already occupied
|
||||
@@ -345,7 +349,7 @@ npm start
|
||||
|
||||
### Database Disconnected
|
||||
**Problem**: Status bar shows "Disconnected"
|
||||
**Solution**: Check `db.config.js` credentials and Supabase project status
|
||||
**Solution**: Check `db.config.js` credentials and PostgreSQL server status
|
||||
|
||||
For more troubleshooting, see [DEPLOYMENT.md](DEPLOYMENT.md)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user