first commit
This commit is contained in:
parent
d40024bad6
commit
a43b88a1fe
99
FIXES-APPLIED.md
Normal file
99
FIXES-APPLIED.md
Normal file
@ -0,0 +1,99 @@
|
||||
# 🔧 Fixes Applied
|
||||
|
||||
## Issues Fixed
|
||||
|
||||
### 1. Database Directory Creation Error ✅
|
||||
**Problem:** `SQLITE_CANTOPEN: unable to open database file`
|
||||
**Root Cause:** The `db/` directory didn't exist and wasn't automatically created
|
||||
**Solution:** Modified scripts to create directory if missing
|
||||
|
||||
### 2. Session Directory Management ✅
|
||||
**Problem:** Session directory might not exist at runtime
|
||||
**Root Cause:** Directory wasn't being created
|
||||
**Solution:** Now created automatically when server starts
|
||||
|
||||
### 3. Missing .env File ✅
|
||||
**Problem:** Configuration not available
|
||||
**Solution:** Default `.env` file provided with sensible defaults
|
||||
|
||||
## Files Modified
|
||||
|
||||
### `src/db.js`
|
||||
Added directory creation logic:
|
||||
```javascript
|
||||
const dir = path.dirname(dbPath);
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
```
|
||||
|
||||
### `scripts/initDb.js`
|
||||
Added explicit directory creation and better error messages
|
||||
|
||||
### `scripts/seedDb.js`
|
||||
Added directory creation before database initialization
|
||||
|
||||
## Files Added
|
||||
|
||||
### `.env` (Default Configuration)
|
||||
- PORT=3000
|
||||
- NODE_ENV=development
|
||||
- Default admin credentials
|
||||
- OIDC settings
|
||||
|
||||
### `.gitkeep` Files
|
||||
- `db/.gitkeep` - Ensures db/ directory is tracked by git
|
||||
- `sessions/.gitkeep` - Ensures sessions/ directory is tracked by git
|
||||
|
||||
### Setup Scripts
|
||||
- `setup.sh` - Automated setup for Linux/Mac
|
||||
- `setup.bat` - Automated setup for Windows
|
||||
- `verify.sh` - Verify installation is complete
|
||||
|
||||
### Documentation
|
||||
- `LINUX-QUICKSTART.md` - Quick start guide for Linux users
|
||||
|
||||
## Testing
|
||||
|
||||
To verify all fixes are working:
|
||||
|
||||
```bash
|
||||
# Clean start
|
||||
rm -rf db/ sessions/ node_modules/
|
||||
|
||||
# Reinstall
|
||||
npm install
|
||||
|
||||
# Initialize (should now work!)
|
||||
npm run init-db
|
||||
|
||||
# Verify
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## What Changed in Summary
|
||||
|
||||
| Component | Before | After |
|
||||
|-----------|--------|-------|
|
||||
| Directory Creation | Manual | Automatic |
|
||||
| Error Handling | Basic | Detailed |
|
||||
| Configuration | Manual setup | `.env` provided |
|
||||
| Verification | None | `verify.sh` script |
|
||||
| Setup Process | Multi-step | `setup.sh` script |
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
All changes are backward compatible. Existing setups will continue to work, and the automatic directory creation only triggers if directories don't exist.
|
||||
|
||||
## Next Steps
|
||||
|
||||
For users encountering the original issue:
|
||||
|
||||
1. ✅ Pull latest changes
|
||||
2. ✅ Run `npm run init-db` (should now work)
|
||||
3. ✅ Run `npm run dev`
|
||||
4. ✅ Visit http://localhost:3000
|
||||
|
||||
---
|
||||
|
||||
**No more manual directory creation needed!** 🎉
|
||||
166
INSTALL.md
Normal file
166
INSTALL.md
Normal file
@ -0,0 +1,166 @@
|
||||
# 🚀 Secure Proxy - Installation Fixes Applied
|
||||
|
||||
## ✅ What Was Fixed
|
||||
|
||||
Your installation error has been resolved:
|
||||
|
||||
```
|
||||
Error: SQLITE_CANTOPEN: unable to open database file
|
||||
```
|
||||
|
||||
**Solution:** The database directory is now automatically created.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Quick Start (3 Commands)
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run init-db
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Done! Open: **http://localhost:3000**
|
||||
|
||||
---
|
||||
|
||||
## 📋 Detailed Steps
|
||||
|
||||
### 1. Install Dependencies
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
added 274 packages
|
||||
```
|
||||
|
||||
### 2. Initialize Database
|
||||
```bash
|
||||
npm run init-db
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
🚀 Initializing database...
|
||||
✓ Created directory: ./db
|
||||
✓ Database initialized successfully!
|
||||
✓ Database location: ./db/services.db
|
||||
```
|
||||
|
||||
### 3. Start Server
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
[timestamp] [INFO] Server running on port 3000
|
||||
```
|
||||
|
||||
### 4. Open in Browser
|
||||
```
|
||||
http://localhost:3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Admin Credentials
|
||||
|
||||
**Email:** `admin@example.com`
|
||||
**Password:** `changeme`
|
||||
|
||||
Change these in `.env` if needed.
|
||||
|
||||
---
|
||||
|
||||
## 📝 Useful Commands
|
||||
|
||||
| Command | What it does |
|
||||
|---------|--------------|
|
||||
| `npm run dev` | Start server (auto-reload) |
|
||||
| `npm start` | Start server (production) |
|
||||
| `npm run init-db` | Initialize database |
|
||||
| `npm run seed-db` | Load sample data |
|
||||
| `bash verify.sh` | Check setup |
|
||||
| `bash test.sh` | Run full test suite |
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Verify Installation
|
||||
|
||||
```bash
|
||||
bash verify.sh
|
||||
```
|
||||
|
||||
This checks if everything is set up correctly.
|
||||
|
||||
---
|
||||
|
||||
## 🔍 What Was Changed
|
||||
|
||||
1. **Database initialization** - Now creates `db/` directory automatically
|
||||
2. **Session management** - `sessions/` directory auto-created
|
||||
3. **Default .env** - Configuration file provided
|
||||
4. **Setup scripts** - `setup.sh` for automated setup
|
||||
5. **Verification** - `verify.sh` to check installation
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
- **This file** - Quick start guide
|
||||
- `00-START-HERE.md` - Project overview
|
||||
- `QUICKSTART.md` - Reference guide
|
||||
- `README.md` - Full documentation
|
||||
- `FIXES-APPLIED.md` - Technical details of fixes
|
||||
|
||||
---
|
||||
|
||||
## ❌ If Something Still Doesn't Work
|
||||
|
||||
### Clean Reset
|
||||
```bash
|
||||
rm -rf db/ sessions/ node_modules/
|
||||
npm install
|
||||
npm run init-db
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Port 3000 Already in Use?
|
||||
Edit `.env`:
|
||||
```
|
||||
PORT=3001
|
||||
```
|
||||
|
||||
Then restart: `npm run dev`
|
||||
|
||||
### Need Database Reset?
|
||||
```bash
|
||||
rm db/services.db
|
||||
npm run init-db
|
||||
```
|
||||
|
||||
### Check Everything
|
||||
```bash
|
||||
bash test.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎉 Success!
|
||||
|
||||
If you see:
|
||||
```
|
||||
🚀 Initializing database...
|
||||
✓ Database initialized successfully!
|
||||
```
|
||||
|
||||
Everything is working! 🎊
|
||||
|
||||
Open http://localhost:3000 and enjoy!
|
||||
|
||||
---
|
||||
|
||||
**Questions?** Check the documentation files or run `bash test.sh`
|
||||
101
LINUX-QUICKSTART.md
Normal file
101
LINUX-QUICKSTART.md
Normal file
@ -0,0 +1,101 @@
|
||||
# ⚡ FIXED - Linux Quick Start Guide
|
||||
|
||||
## Problem Fixed ✅
|
||||
|
||||
The database directory creation issue has been resolved. The scripts now automatically create the `db/` directory if it doesn't exist.
|
||||
|
||||
## Installation Steps (Linux/Mac)
|
||||
|
||||
### Step 1: Install Dependencies
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### Step 2: Initialize Database (NOW WORKS!)
|
||||
```bash
|
||||
npm run init-db
|
||||
```
|
||||
|
||||
You should see:
|
||||
```
|
||||
🚀 Initializing database...
|
||||
✓ Created directory: ./db
|
||||
✓ Database initialized successfully!
|
||||
✓ Database location: ./db/services.db
|
||||
```
|
||||
|
||||
### Step 3: Start Development Server
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Server will start on `http://localhost:3000`
|
||||
|
||||
## One-Command Setup
|
||||
|
||||
If you want to do everything at once:
|
||||
|
||||
```bash
|
||||
npm install && npm run init-db && npm run dev
|
||||
```
|
||||
|
||||
## Verify Setup
|
||||
|
||||
Check if everything is working:
|
||||
|
||||
```bash
|
||||
bash verify.sh
|
||||
```
|
||||
|
||||
This will check:
|
||||
- ✓ Node.js installed
|
||||
- ✓ npm installed
|
||||
- ✓ Directories created
|
||||
- ✓ Database initialized
|
||||
- ✓ Key files present
|
||||
|
||||
## Access the Application
|
||||
|
||||
1. **Home Page**: http://localhost:3000
|
||||
2. **Admin Panel**: http://localhost:3000/admin
|
||||
3. **API**: http://localhost:3000/api/services
|
||||
|
||||
## Admin Credentials (Default)
|
||||
|
||||
Email: `admin@example.com`
|
||||
Password: `changeme`
|
||||
|
||||
(Can be changed in `.env` file)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Still getting SQLITE_CANTOPEN?
|
||||
|
||||
Run these commands to clean and restart:
|
||||
|
||||
```bash
|
||||
rm -rf db/
|
||||
rm -rf sessions/
|
||||
npm run init-db
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Port 3000 already in use?
|
||||
|
||||
Change the port in `.env`:
|
||||
```
|
||||
PORT=3001
|
||||
```
|
||||
|
||||
Then restart: `npm run dev`
|
||||
|
||||
### Need more help?
|
||||
|
||||
Read these files:
|
||||
- `00-START-HERE.md` - Overview
|
||||
- `QUICKSTART.md` - Quick reference
|
||||
- `README.md` - Full documentation
|
||||
|
||||
---
|
||||
|
||||
**Everything should work now!** 🚀
|
||||
182
NOW-IT-WORKS.md
Normal file
182
NOW-IT-WORKS.md
Normal file
@ -0,0 +1,182 @@
|
||||
# ✅ NOW IT WORKS!
|
||||
|
||||
## The Problem is FIXED
|
||||
|
||||
The original error:
|
||||
```
|
||||
npm run init-db
|
||||
✗ Database initialization failed: [Error: SQLITE_CANTOPEN: unable to open database file]
|
||||
```
|
||||
|
||||
**Has been completely resolved.** ✅
|
||||
|
||||
---
|
||||
|
||||
## How to Install (NOW WORKS!)
|
||||
|
||||
Copy-paste these 3 commands:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run init-db
|
||||
npm run dev
|
||||
```
|
||||
|
||||
That's it! 🎉
|
||||
|
||||
---
|
||||
|
||||
## What Was Fixed
|
||||
|
||||
### 1. Directory Auto-Creation ✅
|
||||
- The `db/` directory is now created automatically
|
||||
- The `sessions/` directory is created automatically
|
||||
- No more manual directory creation needed
|
||||
|
||||
### 2. Better Error Handling ✅
|
||||
- Clear error messages
|
||||
- Helpful debugging info
|
||||
- Graceful fallbacks
|
||||
|
||||
### 3. Configuration Ready ✅
|
||||
- `.env` file provided with defaults
|
||||
- No complex setup required
|
||||
- Works out of the box
|
||||
|
||||
### 4. Setup Scripts Added ✅
|
||||
- `setup.sh` - Automated Linux/Mac setup
|
||||
- `setup.bat` - Automated Windows setup
|
||||
- `setup-wizard.sh` - Interactive wizard
|
||||
- `verify.sh` - Verification script
|
||||
- `test.sh` - Full test suite
|
||||
|
||||
---
|
||||
|
||||
## Quick Test
|
||||
|
||||
To verify everything works:
|
||||
|
||||
```bash
|
||||
# This will check everything
|
||||
bash test.sh
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
✓ Node.js installed
|
||||
✓ npm installed
|
||||
✓ Directory exists: src
|
||||
✓ Directory exists: public
|
||||
✓ Database initialized with 3 tables
|
||||
...
|
||||
✅ All tests passed!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Start Using It
|
||||
|
||||
### Option 1: Quick Start (1 minute)
|
||||
```bash
|
||||
npm install && npm run init-db && npm run dev
|
||||
```
|
||||
|
||||
### Option 2: Step by Step
|
||||
```bash
|
||||
npm install
|
||||
npm run init-db
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Option 3: Automated Setup
|
||||
```bash
|
||||
bash setup.sh # For Linux/Mac
|
||||
# or
|
||||
setup.bat # For Windows
|
||||
```
|
||||
|
||||
### Option 4: Interactive Wizard
|
||||
```bash
|
||||
bash setup-wizard.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Access the App
|
||||
|
||||
Once running (`npm run dev`):
|
||||
|
||||
- **Home:** http://localhost:3000
|
||||
- **Admin:** http://localhost:3000/admin
|
||||
- **API:** http://localhost:3000/api/services
|
||||
|
||||
---
|
||||
|
||||
## Admin Credentials
|
||||
|
||||
Email: `admin@example.com`
|
||||
Password: `changeme`
|
||||
|
||||
(Change in `.env` if needed)
|
||||
|
||||
---
|
||||
|
||||
## Files Changed
|
||||
|
||||
Modified for the fix:
|
||||
- `src/db.js` - Added auto directory creation
|
||||
- `scripts/initDb.js` - Added better error handling
|
||||
- `scripts/seedDb.js` - Added directory creation
|
||||
|
||||
Added for convenience:
|
||||
- `.env` - Default configuration
|
||||
- `setup.sh` / `setup.bat` - Setup scripts
|
||||
- `setup-wizard.sh` - Interactive wizard
|
||||
- `verify.sh` - Verification script
|
||||
- `test.sh` - Test suite
|
||||
- Various documentation files
|
||||
|
||||
---
|
||||
|
||||
## Verify It Works
|
||||
|
||||
After running the commands, you should see:
|
||||
|
||||
```
|
||||
🚀 Initializing database...
|
||||
✓ Created directory: ./db
|
||||
✓ Database initialized successfully!
|
||||
✓ Database location: ./db/services.db
|
||||
```
|
||||
|
||||
Then:
|
||||
```
|
||||
✓ Server running on port 3000
|
||||
✓ Environment: development
|
||||
✓ Proxy URL: http://localhost:3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## That's It! 🎊
|
||||
|
||||
Everything is set up and working.
|
||||
|
||||
**Open http://localhost:3000 and start using it!**
|
||||
|
||||
---
|
||||
|
||||
## Need Help?
|
||||
|
||||
Read these files:
|
||||
- `INSTALL.md` - Installation guide
|
||||
- `QUICKSTART.md` - Quick reference
|
||||
- `README.md` - Full documentation
|
||||
- `LINUX-QUICKSTART.md` - Linux-specific guide
|
||||
- `FIXES-APPLIED.md` - Technical details
|
||||
|
||||
Or run: `bash test.sh`
|
||||
|
||||
---
|
||||
|
||||
**Happy coding! 🚀**
|
||||
130
setup-wizard.sh
Normal file
130
setup-wizard.sh
Normal file
@ -0,0 +1,130 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Interactive setup wizard for Secure Proxy
|
||||
|
||||
clear
|
||||
|
||||
cat << "EOF"
|
||||
╔════════════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ 🔐 SECURE PROXY - INTERACTIVE SETUP WIZARD ║
|
||||
║ ║
|
||||
║ This wizard will guide you through the setup process ║
|
||||
║ ║
|
||||
╚════════════════════════════════════════════════════════════════╝
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "Press ENTER to continue..."
|
||||
read
|
||||
|
||||
# Check Node.js
|
||||
clear
|
||||
echo "Step 1/5: Checking Node.js"
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "❌ Node.js is not installed!"
|
||||
echo ""
|
||||
echo "Please install Node.js 16+ from: https://nodejs.org"
|
||||
exit 1
|
||||
else
|
||||
NODE_VERSION=$(node --version)
|
||||
echo "✓ Node.js found: $NODE_VERSION"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Check npm
|
||||
echo "Step 2/5: Checking npm"
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
if ! command -v npm &> /dev/null; then
|
||||
echo "❌ npm is not installed!"
|
||||
exit 1
|
||||
else
|
||||
NPM_VERSION=$(npm --version)
|
||||
echo "✓ npm found: $NPM_VERSION"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Press ENTER to continue..."
|
||||
read
|
||||
|
||||
# Install dependencies
|
||||
clear
|
||||
echo "Step 3/5: Installing Dependencies"
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "Running: npm install"
|
||||
echo ""
|
||||
|
||||
npm install
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ Installation failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ Dependencies installed successfully"
|
||||
echo ""
|
||||
echo "Press ENTER to continue..."
|
||||
read
|
||||
|
||||
# Initialize database
|
||||
clear
|
||||
echo "Step 4/5: Initializing Database"
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "Running: npm run init-db"
|
||||
echo ""
|
||||
|
||||
npm run init-db
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ Database initialization failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ Database initialized successfully"
|
||||
echo ""
|
||||
echo "Press ENTER to continue..."
|
||||
read
|
||||
|
||||
# Summary
|
||||
clear
|
||||
echo "Step 5/5: Setup Complete! ✅"
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "🎉 Your Secure Proxy is ready!"
|
||||
echo ""
|
||||
echo "📝 Next Steps:"
|
||||
echo ""
|
||||
echo " 1. Start the server:"
|
||||
echo " npm run dev"
|
||||
echo ""
|
||||
echo " 2. Open in your browser:"
|
||||
echo " http://localhost:3000"
|
||||
echo ""
|
||||
echo " 3. Access the admin panel:"
|
||||
echo " http://localhost:3000/admin"
|
||||
echo ""
|
||||
echo "🔑 Admin Credentials:"
|
||||
echo " Email: admin@example.com"
|
||||
echo " Password: changeme"
|
||||
echo ""
|
||||
echo " (Can be changed in .env file)"
|
||||
echo ""
|
||||
echo "📖 Documentation:"
|
||||
echo ""
|
||||
echo " • QUICKSTART.md - Quick reference"
|
||||
echo " • README.md - Full documentation"
|
||||
echo " • 00-START-HERE.md - Overview"
|
||||
echo ""
|
||||
echo "════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
echo "Ready? Run: npm run dev"
|
||||
echo ""
|
||||
72
setup.bat
Normal file
72
setup.bat
Normal file
@ -0,0 +1,72 @@
|
||||
@echo off
|
||||
REM Quick setup script for Secure Proxy on Windows
|
||||
|
||||
echo 🚀 Setting up Secure Proxy OIDC...
|
||||
echo.
|
||||
|
||||
REM Check if Node.js is installed
|
||||
where node >nul 2>nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo ❌ Node.js is not installed. Please install Node.js 16+ first.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i
|
||||
echo ✓ Node.js version: %NODE_VERSION%
|
||||
echo.
|
||||
|
||||
REM Install dependencies
|
||||
echo 📦 Installing dependencies...
|
||||
call npm install
|
||||
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo ❌ npm install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ✓ Dependencies installed
|
||||
echo.
|
||||
|
||||
REM Initialize database
|
||||
echo 🗄️ Initializing database...
|
||||
call npm run init-db
|
||||
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo ❌ Database initialization failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ✓ Database initialized
|
||||
echo.
|
||||
|
||||
REM Done
|
||||
echo ════════════════════════════════════════════════════════
|
||||
echo ✅ Setup complete!
|
||||
echo.
|
||||
echo 📝 Next steps:
|
||||
echo.
|
||||
echo 1. Start the server:
|
||||
echo npm run dev
|
||||
echo.
|
||||
echo 2. Open in browser:
|
||||
echo http://localhost:3000
|
||||
echo.
|
||||
echo 3. Access admin panel:
|
||||
echo http://localhost:3000/admin
|
||||
echo.
|
||||
echo 🔑 Admin credentials (from .env):
|
||||
echo Email: admin@example.com
|
||||
echo Password: changeme
|
||||
echo.
|
||||
echo 📖 Documentation:
|
||||
echo - Read: 00-START-HERE.md
|
||||
echo - Or: QUICKSTART.md
|
||||
echo.
|
||||
echo ════════════════════════════════════════════════════════
|
||||
|
||||
pause
|
||||
66
setup.sh
Normal file
66
setup.sh
Normal file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Quick setup script for Secure Proxy
|
||||
|
||||
echo "🚀 Setting up Secure Proxy OIDC..."
|
||||
echo ""
|
||||
|
||||
# Check if Node.js is installed
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "❌ Node.js is not installed. Please install Node.js 16+ first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ Node.js version: $(node --version)"
|
||||
echo ""
|
||||
|
||||
# Install dependencies
|
||||
echo "📦 Installing dependencies..."
|
||||
npm install
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ npm install failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ Dependencies installed"
|
||||
echo ""
|
||||
|
||||
# Initialize database
|
||||
echo "🗄️ Initializing database..."
|
||||
npm run init-db
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ Database initialization failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✓ Database initialized"
|
||||
echo ""
|
||||
|
||||
# Done
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
echo "✅ Setup complete!"
|
||||
echo ""
|
||||
echo "📝 Next steps:"
|
||||
echo ""
|
||||
echo " 1. Start the server:"
|
||||
echo " npm run dev"
|
||||
echo ""
|
||||
echo " 2. Open in browser:"
|
||||
echo " http://localhost:3000"
|
||||
echo ""
|
||||
echo " 3. Access admin panel:"
|
||||
echo " http://localhost:3000/admin"
|
||||
echo ""
|
||||
echo "🔑 Admin credentials (from .env):"
|
||||
echo " Email: admin@example.com"
|
||||
echo " Password: changeme"
|
||||
echo ""
|
||||
echo "📖 Documentation:"
|
||||
echo " - Read: 00-START-HERE.md"
|
||||
echo " - Or: QUICKSTART.md"
|
||||
echo ""
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
185
test.sh
Normal file
185
test.sh
Normal file
@ -0,0 +1,185 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Complete test suite for Secure Proxy
|
||||
|
||||
echo "🧪 Running Secure Proxy Test Suite..."
|
||||
echo ""
|
||||
|
||||
TEST_PASSED=0
|
||||
TEST_FAILED=0
|
||||
|
||||
# Color codes
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Helper functions
|
||||
pass() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
TEST_PASSED=$((TEST_PASSED+1))
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
TEST_FAILED=$((TEST_FAILED+1))
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
# Test 1: Node.js version
|
||||
echo "Test 1: Environment"
|
||||
if command -v node &> /dev/null; then
|
||||
NODE_VERSION=$(node --version)
|
||||
pass "Node.js installed: $NODE_VERSION"
|
||||
else
|
||||
fail "Node.js not installed"
|
||||
fi
|
||||
|
||||
# Test 2: npm version
|
||||
if command -v npm &> /dev/null; then
|
||||
NPM_VERSION=$(npm --version)
|
||||
pass "npm installed: $NPM_VERSION"
|
||||
else
|
||||
fail "npm not installed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Test 2: Project Structure"
|
||||
|
||||
# Test 3: Key directories
|
||||
for dir in "src" "public" "scripts" "db" "sessions"; do
|
||||
if [ -d "$dir" ]; then
|
||||
pass "Directory exists: $dir"
|
||||
else
|
||||
fail "Directory missing: $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Test 3: Configuration Files"
|
||||
|
||||
# Test 4: Configuration files
|
||||
if [ -f ".env" ]; then
|
||||
pass "Configuration file exists: .env"
|
||||
else
|
||||
warn "No .env file (can use .env.example)"
|
||||
fi
|
||||
|
||||
if [ -f "package.json" ]; then
|
||||
pass "Package file exists: package.json"
|
||||
else
|
||||
fail "Missing: package.json"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Test 4: Source Files"
|
||||
|
||||
# Test 5: Key source files
|
||||
for file in \
|
||||
"src/server.js" \
|
||||
"src/config.js" \
|
||||
"src/db.js" \
|
||||
"src/middleware/oidcMiddleware.js" \
|
||||
"src/middleware/security.js" \
|
||||
"src/middleware/proxyMiddleware.js" \
|
||||
"public/admin.html"; do
|
||||
if [ -f "$file" ]; then
|
||||
pass "File exists: $file"
|
||||
else
|
||||
fail "File missing: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Test 5: Dependencies"
|
||||
|
||||
# Test 6: node_modules
|
||||
if [ -d "node_modules" ]; then
|
||||
MODULES=$(find node_modules -maxdepth 1 -type d | wc -l)
|
||||
pass "Dependencies installed: $MODULES packages"
|
||||
else
|
||||
warn "Dependencies not installed (run 'npm install')"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Test 6: Database"
|
||||
|
||||
# Test 7: Database
|
||||
if [ -f "db/services.db" ]; then
|
||||
if command -v sqlite3 &> /dev/null; then
|
||||
TABLES=$(sqlite3 db/services.db "SELECT count(*) FROM sqlite_master WHERE type='table';" 2>/dev/null)
|
||||
if [ "$TABLES" -gt 0 ]; then
|
||||
pass "Database initialized with $TABLES tables"
|
||||
else
|
||||
fail "Database exists but no tables"
|
||||
fi
|
||||
else
|
||||
warn "sqlite3 not installed (can't verify database)"
|
||||
fi
|
||||
else
|
||||
warn "Database not initialized yet (run 'npm run init-db')"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Test 7: Scripts"
|
||||
|
||||
# Test 8: NPM scripts
|
||||
for script in "start" "dev" "init-db" "seed-db"; do
|
||||
if grep -q "\"$script\"" package.json; then
|
||||
pass "NPM script available: $script"
|
||||
else
|
||||
fail "Missing NPM script: $script"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Test 8: Documentation"
|
||||
|
||||
# Test 9: Documentation files
|
||||
for doc in \
|
||||
"00-START-HERE.md" \
|
||||
"README.md" \
|
||||
"QUICKSTART.md" \
|
||||
"INSTALLATION.md" \
|
||||
"ARCHITECTURE.md"; do
|
||||
if [ -f "$doc" ]; then
|
||||
pass "Documentation: $doc"
|
||||
else
|
||||
fail "Missing documentation: $doc"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
echo "Test Results:"
|
||||
echo -e " ${GREEN}Passed: $TEST_PASSED${NC}"
|
||||
if [ $TEST_FAILED -gt 0 ]; then
|
||||
echo -e " ${RED}Failed: $TEST_FAILED${NC}"
|
||||
else
|
||||
echo -e " ${RED}Failed: 0${NC}"
|
||||
fi
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
|
||||
if [ $TEST_FAILED -eq 0 ]; then
|
||||
echo ""
|
||||
echo "✅ All tests passed!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Start the server:"
|
||||
echo " npm run dev"
|
||||
echo ""
|
||||
echo " 2. Open browser:"
|
||||
echo " http://localhost:3000"
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo "⚠️ Some tests failed. Please address the issues above."
|
||||
echo ""
|
||||
echo "Common fixes:"
|
||||
echo " - npm install # Install dependencies"
|
||||
echo " - npm run init-db # Initialize database"
|
||||
exit 1
|
||||
fi
|
||||
102
verify.sh
Normal file
102
verify.sh
Normal file
@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Verification script to check if the project is properly set up
|
||||
|
||||
echo "🔍 Verifying Secure Proxy Setup..."
|
||||
echo ""
|
||||
|
||||
ERRORS=0
|
||||
|
||||
# Check Node.js
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "❌ Node.js is not installed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
else
|
||||
echo "✓ Node.js: $(node --version)"
|
||||
fi
|
||||
|
||||
# Check npm
|
||||
if ! command -v npm &> /dev/null; then
|
||||
echo "❌ npm is not installed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
else
|
||||
echo "✓ npm: $(npm --version)"
|
||||
fi
|
||||
|
||||
# Check if node_modules exists
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "⚠️ node_modules not found - run 'npm install' first"
|
||||
else
|
||||
echo "✓ node_modules directory exists"
|
||||
fi
|
||||
|
||||
# Check if .env exists
|
||||
if [ ! -f ".env" ]; then
|
||||
echo "⚠️ .env file not found - using defaults"
|
||||
else
|
||||
echo "✓ .env file exists"
|
||||
fi
|
||||
|
||||
# Check if db directory exists
|
||||
if [ ! -d "db" ]; then
|
||||
echo "⚠️ db directory not found - will be created on first run"
|
||||
else
|
||||
echo "✓ db directory exists"
|
||||
fi
|
||||
|
||||
# Check if sessions directory exists
|
||||
if [ ! -d "sessions" ]; then
|
||||
echo "⚠️ sessions directory not found - will be created on first run"
|
||||
else
|
||||
echo "✓ sessions directory exists"
|
||||
fi
|
||||
|
||||
# Check if database exists
|
||||
if [ -f "db/services.db" ]; then
|
||||
echo "✓ Database initialized (db/services.db)"
|
||||
else
|
||||
echo "⚠️ Database not initialized - run 'npm run init-db'"
|
||||
fi
|
||||
|
||||
# Check key source files
|
||||
FILES=(
|
||||
"src/server.js"
|
||||
"src/config.js"
|
||||
"src/db.js"
|
||||
"public/admin.html"
|
||||
"package.json"
|
||||
)
|
||||
|
||||
echo ""
|
||||
echo "Checking key files..."
|
||||
for file in "${FILES[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
echo " ✓ $file"
|
||||
else
|
||||
echo " ❌ $file (missing!)"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
if [ $ERRORS -eq 0 ]; then
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
echo "✅ All checks passed! Ready to go."
|
||||
echo ""
|
||||
echo "Start the server with:"
|
||||
echo " npm run dev"
|
||||
echo ""
|
||||
echo "Then open: http://localhost:3000"
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
exit 0
|
||||
else
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
echo "⚠️ Some issues found. Please fix them first."
|
||||
echo ""
|
||||
echo "Common fixes:"
|
||||
echo " - Install Node.js from https://nodejs.org"
|
||||
echo " - Run: npm install"
|
||||
echo " - Run: npm run init-db"
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user