API: Phoenix railing proxy, API key auth for /api/v1/*, schema export, docs, migrations, tests

- Phoenix API Railing: proxy to PHOENIX_RAILING_URL, tenant me routes
- Tenant-auth: X-API-Key support for /api/v1/* (api_keys table)
- Migration 026: api_keys table; 025 sovereign stack marketplace
- GET /graphql/schema, GET /graphql-playground, api/docs OpenAPI
- Integration tests: phoenix-railing.test.ts
- docs/api/API_VERSIONING: /api/v1/ railing alignment
- docs/phoenix/PORTAL_RAILING_WIRING

Made-with: Cursor
This commit is contained in:
defiQUG
2026-03-11 12:57:41 -07:00
parent 33b02b636b
commit 8436e22f4c
45 changed files with 4308 additions and 17 deletions

100
api/scripts/auto-setup-db.sh Executable file
View File

@@ -0,0 +1,100 @@
#!/bin/bash
# Automated database setup - tries multiple methods
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$API_DIR"
echo "=========================================="
echo "Automated Database Setup"
echo "=========================================="
echo ""
# Ensure .env exists with correct password
if [ ! -f .env ]; then
cat > .env << 'ENVEOF'
DB_HOST=localhost
DB_PORT=5432
DB_NAME=sankofa
DB_USER=postgres
DB_PASSWORD=dev_sankofa_2024_secure
NODE_ENV=development
PORT=4000
ENVEOF
echo "✅ Created .env file"
else
# Update password in .env
if ! grep -q "^DB_PASSWORD=dev_sankofa_2024_secure" .env; then
sed -i 's|^DB_PASSWORD=.*|DB_PASSWORD=dev_sankofa_2024_secure|' .env || echo "DB_PASSWORD=dev_sankofa_2024_secure" >> .env
echo "✅ Updated .env with password"
fi
# Ensure NODE_ENV is development
if ! grep -q "^NODE_ENV=development" .env; then
sed -i 's|^NODE_ENV=.*|NODE_ENV=development|' .env || echo "NODE_ENV=development" >> .env
fi
fi
echo ""
echo "Attempting to set up database..."
echo ""
# Method 1: Try with sudo (may require password)
echo "Method 1: Trying with sudo..."
if sudo -n true 2>/dev/null; then
echo "Sudo access available (no password required)"
sudo -u postgres psql -c "CREATE DATABASE sankofa;" 2>/dev/null && echo "✅ Database created" || echo "Database may already exist"
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'dev_sankofa_2024_secure';" 2>/dev/null && echo "✅ Password set" || echo "⚠ Could not set password (may already be set)"
else
echo "⚠ Sudo requires password - will try other methods"
fi
# Method 2: Try direct connection
echo ""
echo "Method 2: Trying direct PostgreSQL connection..."
if psql -U postgres -d postgres -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ Can connect to PostgreSQL"
psql -U postgres -d postgres -c "CREATE DATABASE sankofa;" 2>/dev/null && echo "✅ Database created" || echo "Database may already exist"
psql -U postgres -d postgres -c "ALTER USER postgres PASSWORD 'dev_sankofa_2024_secure';" 2>/dev/null && echo "✅ Password set" || echo "⚠ Could not set password"
else
echo "⚠ Cannot connect directly"
fi
# Method 3: Try with createdb
echo ""
echo "Method 3: Trying createdb command..."
if command -v createdb >/dev/null 2>&1; then
createdb -U postgres sankofa 2>/dev/null && echo "✅ Database created" || echo "Database may already exist"
else
echo "⚠ createdb command not found"
fi
# Final test
echo ""
echo "Testing database connection..."
sleep 1
if PGPASSWORD="dev_sankofa_2024_secure" psql -h localhost -U postgres -d sankofa -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ Database connection successful!"
echo ""
echo "Database is ready. You can now run:"
echo " ./RUN_ME.sh"
echo ""
exit 0
else
echo "❌ Database connection failed"
echo ""
echo "Please run manually:"
echo ""
echo " sudo -u postgres psql << EOSQL"
echo " CREATE DATABASE sankofa;"
echo " ALTER USER postgres PASSWORD 'dev_sankofa_2024_secure';"
echo " \\q"
echo " EOSQL"
echo ""
echo "Or see: setup-db-commands.txt"
echo ""
exit 1
fi

31
api/scripts/create-env.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# Helper script to create .env file from .env.example
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$API_DIR"
if [ -f .env ]; then
echo "⚠ .env file already exists. Skipping creation."
echo "If you want to recreate it, delete .env first."
exit 0
fi
if [ ! -f .env.example ]; then
echo "❌ .env.example not found. Cannot create .env file."
exit 1
fi
echo "Creating .env file from .env.example..."
cp .env.example .env
echo ""
echo "✅ .env file created!"
echo ""
echo "⚠ IMPORTANT: Please edit .env and set your database password:"
echo " DB_PASSWORD=your_secure_password_here"
echo ""
echo "For development: minimum 8 characters"
echo "For production: minimum 32 characters with uppercase, lowercase, numbers, and special characters"
echo ""

106
api/scripts/manual-db-setup.sh Executable file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
# Manual database setup script - run this with appropriate permissions
echo "=========================================="
echo "Manual Database Setup for Sovereign Stack"
echo "=========================================="
echo ""
echo "This script will help you set up the database."
echo "You may need to run some commands with sudo."
echo ""
# Check if database exists
echo "Step 1: Checking if database 'sankofa' exists..."
if psql -U postgres -lqt 2>/dev/null | cut -d \| -f 1 | grep -qw sankofa; then
echo "✅ Database 'sankofa' already exists"
else
echo "Database 'sankofa' not found."
echo ""
echo "Please run ONE of the following commands:"
echo ""
echo "Option A (if you have sudo access):"
echo " sudo -u postgres createdb sankofa"
echo ""
echo "Option B (if you have postgres user access):"
echo " createdb -U postgres sankofa"
echo ""
echo "Option C (if you have a different PostgreSQL user):"
echo " createdb -U your_user sankofa"
echo ""
read -p "Press Enter after you've created the database..."
fi
# Check current password
echo ""
echo "Step 2: Testing database connection..."
echo "Current .env password: $(grep '^DB_PASSWORD=' .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' | tr -d "'" || echo 'not set')"
echo ""
# Try to connect
DB_PASS=$(grep "^DB_PASSWORD=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
if [ -n "$DB_PASS" ] && [ "$DB_PASS" != "your_secure_password_here" ]; then
if PGPASSWORD="$DB_PASS" psql -h localhost -U postgres -d sankofa -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ Database connection successful with current password"
CONNECTION_OK=true
else
echo "❌ Database connection failed with current password"
CONNECTION_OK=false
fi
else
echo "⚠ No valid password set in .env"
CONNECTION_OK=false
fi
if [ "$CONNECTION_OK" != "true" ]; then
echo ""
echo "You need to set the correct PostgreSQL password."
echo ""
echo "Option 1: Set password for postgres user"
echo " Run: sudo -u postgres psql"
echo " Then: ALTER USER postgres PASSWORD 'your_password';"
echo " Then: \\q"
echo ""
echo "Option 2: Update .env with existing password"
echo " Edit .env and set DB_PASSWORD to your actual PostgreSQL password"
echo ""
read -p "Press Enter when password is configured..."
# Update .env if user wants
echo ""
read -p "Would you like to update .env with a new password now? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
read -sp "Enter PostgreSQL password: " NEW_PASS
echo ""
if [ -n "$NEW_PASS" ]; then
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$NEW_PASS|" .env
echo "✅ .env updated"
fi
fi
fi
# Final connection test
echo ""
echo "Step 3: Final connection test..."
DB_PASS=$(grep "^DB_PASSWORD=" .env | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
if PGPASSWORD="$DB_PASS" psql -h localhost -U postgres -d sankofa -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ Database connection successful!"
echo ""
echo "You can now run:"
echo " ./scripts/setup-sovereign-stack.sh"
echo ""
echo "Or continue with migrations:"
echo " pnpm db:migrate:up"
echo " pnpm db:seed:sovereign-stack"
echo " pnpm verify:sovereign-stack"
else
echo "❌ Database connection still failing"
echo ""
echo "Please:"
echo " 1. Verify PostgreSQL is running: sudo systemctl status postgresql"
echo " 2. Verify database exists: psql -U postgres -l | grep sankofa"
echo " 3. Verify password is correct in .env"
echo " 4. Try connecting manually: psql -U postgres -d sankofa"
fi

136
api/scripts/quick-setup.sh Executable file
View File

@@ -0,0 +1,136 @@
#!/bin/bash
# Quick setup that handles database creation and password setup
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$API_DIR"
echo "=========================================="
echo "Sovereign Stack - Quick Setup"
echo "=========================================="
echo ""
# Step 1: Ensure .env exists
if [ ! -f .env ]; then
echo "Creating .env file..."
cp .env.example .env 2>/dev/null || {
cat > .env << 'EOF'
DB_HOST=localhost
DB_PORT=5432
DB_NAME=sankofa
DB_USER=postgres
DB_PASSWORD=
NODE_ENV=development
PORT=4000
EOF
}
fi
# Step 2: Check if database exists, create if not
echo "Checking database..."
DB_EXISTS=$(sudo -u postgres psql -lqt 2>/dev/null | cut -d \| -f 1 | grep -w sankofa | wc -l)
if [ "$DB_EXISTS" -eq 0 ]; then
echo "Database 'sankofa' not found. Creating..."
sudo -u postgres createdb sankofa 2>/dev/null && echo "✅ Database created" || {
echo "⚠ Could not create database automatically."
echo "Please run manually: sudo -u postgres createdb sankofa"
}
else
echo "✅ Database 'sankofa' exists"
fi
# Step 3: Get database password
CURRENT_PASS=$(grep "^DB_PASSWORD=" .env 2>/dev/null | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
if [ -z "$CURRENT_PASS" ] || [ "$CURRENT_PASS" = "your_secure_password_here" ] || [ "$CURRENT_PASS" = "YOUR_ACTUAL_DATABASE_PASSWORD_HERE" ]; then
echo ""
echo "Database password needed."
echo ""
echo "Options:"
echo " 1. Enter your PostgreSQL password"
echo " 2. Set a new password for postgres user (recommended for development)"
echo ""
read -p "Choose option (1 or 2): " OPTION
if [ "$OPTION" = "2" ]; then
echo ""
echo "Setting new password for postgres user..."
read -sp "Enter new password (min 8 chars): " NEW_PASS
echo ""
sudo -u postgres psql -c "ALTER USER postgres PASSWORD '$NEW_PASS';" 2>/dev/null && {
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$NEW_PASS|" .env
echo "✅ Password set and .env updated"
} || {
echo "❌ Failed to set password. Please set manually."
exit 1
}
else
echo ""
read -sp "Enter PostgreSQL password: " DB_PASS
echo ""
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
echo "✅ Password updated in .env"
fi
fi
# Ensure NODE_ENV is development
if ! grep -q "^NODE_ENV=development" .env; then
sed -i 's/^NODE_ENV=.*/NODE_ENV=development/' .env || echo "NODE_ENV=development" >> .env
fi
# Step 4: Test connection
echo ""
echo "Testing database connection..."
DB_PASS=$(grep "^DB_PASSWORD=" .env | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
if PGPASSWORD="$DB_PASS" psql -h localhost -U postgres -d sankofa -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ Database connection successful"
else
echo "❌ Database connection failed"
echo ""
echo "Please verify:"
echo " 1. PostgreSQL is running: sudo systemctl status postgresql"
echo " 2. Password is correct in .env"
echo " 3. Database exists: sudo -u postgres psql -l | grep sankofa"
echo ""
echo "You can reset the postgres password with:"
echo " sudo -u postgres psql -c \"ALTER USER postgres PASSWORD 'your_password';\""
exit 1
fi
# Step 5: Run migrations
echo ""
echo "Step 1: Running database migrations..."
echo "----------------------------------------"
pnpm db:migrate:up || {
echo "❌ Migration failed"
exit 1
}
echo "✅ Migrations completed"
# Step 6: Seed services
echo ""
echo "Step 2: Seeding Sovereign Stack services..."
echo "----------------------------------------"
pnpm db:seed:sovereign-stack || {
echo "❌ Seeding failed"
exit 1
}
echo "✅ Services seeded"
# Step 7: Verify
echo ""
echo "Step 3: Verifying setup..."
echo "----------------------------------------"
pnpm verify:sovereign-stack || {
echo "⚠ Verification found issues"
exit 1
}
echo ""
echo "=========================================="
echo "✅ Sovereign Stack setup complete!"
echo "=========================================="

View File

@@ -0,0 +1,93 @@
#!/bin/bash
# Setup script for Sovereign Stack marketplace services
# This script runs migrations and seeds the marketplace
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$API_DIR"
echo "=========================================="
echo "Sovereign Stack Marketplace Setup"
echo "=========================================="
echo ""
echo "This script will:"
echo " 1. Run database migrations (adds new categories)"
echo " 2. Seed all 9 Sovereign Stack services"
echo " 3. Verify the setup"
echo ""
# Check if .env exists
if [ ! -f .env ]; then
echo "⚠ Warning: .env file not found."
echo ""
echo "Would you like to create one from .env.example? (y/N)"
read -p "> " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -f .env.example ]; then
./scripts/create-env.sh
echo ""
echo "⚠ Please edit .env and set your database password before continuing."
echo "Press Enter when ready, or Ctrl+C to exit..."
read
else
echo "❌ .env.example not found. Please create .env manually."
exit 1
fi
else
echo ""
echo "Please create a .env file with the following variables:"
echo " DB_HOST=localhost"
echo " DB_PORT=5432"
echo " DB_NAME=sankofa"
echo " DB_USER=postgres"
echo " DB_PASSWORD=your_password_here"
echo ""
echo "For development, DB_PASSWORD must be at least 8 characters."
echo "For production, DB_PASSWORD must be at least 32 characters with uppercase, lowercase, numbers, and special characters."
echo ""
read -p "Press Enter when .env is ready, or Ctrl+C to exit..."
fi
fi
# Step 1: Run migrations
echo "Step 1: Running database migrations..."
echo "----------------------------------------"
pnpm db:migrate:up || {
echo "❌ Migration failed. Please check database connection and try again."
exit 1
}
echo "✅ Migrations completed"
echo ""
# Step 2: Seed Sovereign Stack services
echo "Step 2: Seeding Sovereign Stack services..."
echo "----------------------------------------"
pnpm db:seed:sovereign-stack || {
echo "❌ Seeding failed. Please check the error above."
exit 1
}
echo "✅ Services seeded"
echo ""
# Step 3: Verify setup
echo "Step 3: Verifying setup..."
echo "----------------------------------------"
pnpm verify:sovereign-stack || {
echo "⚠ Verification found issues. Please review the output above."
exit 1
}
echo ""
echo "=========================================="
echo "✅ Sovereign Stack setup complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Access the marketplace at: https://portal.sankofa.nexus/marketplace"
echo "2. Browse Phoenix Cloud Services offerings"
echo "3. Subscribe to services as needed"
echo ""

View File

@@ -0,0 +1,119 @@
#!/bin/bash
# Interactive setup script that prompts for database password
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$API_DIR"
echo "=========================================="
echo "Sovereign Stack Marketplace Setup"
echo "=========================================="
echo ""
# Check if .env exists, if not create from template
if [ ! -f .env ]; then
echo "Creating .env file..."
if [ -f .env.example ]; then
cp .env.example .env
else
cat > .env << 'ENVEOF'
DB_HOST=localhost
DB_PORT=5432
DB_NAME=sankofa
DB_USER=postgres
DB_PASSWORD=
NODE_ENV=development
PORT=4000
ENVEOF
fi
echo "✅ .env file created"
echo ""
fi
# Check if DB_PASSWORD is set and not placeholder
CURRENT_PASSWORD=$(grep "^DB_PASSWORD=" .env | cut -d'=' -f2- | tr -d '"' | tr -d "'")
if [ -z "$CURRENT_PASSWORD" ] || [ "$CURRENT_PASSWORD" = "your_secure_password_here" ] || [ "$CURRENT_PASSWORD" = "YOUR_ACTUAL_DATABASE_PASSWORD_HERE" ]; then
echo "⚠ Database password not set or using placeholder."
echo ""
echo "Please enter your PostgreSQL database password:"
echo "(For development: minimum 8 characters)"
read -s DB_PASS
echo ""
if [ -z "$DB_PASS" ]; then
echo "❌ Password cannot be empty"
exit 1
fi
# Update .env with actual password
if grep -q "^DB_PASSWORD=" .env; then
sed -i "s|^DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env
else
echo "DB_PASSWORD=$DB_PASS" >> .env
fi
echo "✅ Password updated in .env"
echo ""
fi
# Ensure NODE_ENV is set to development
if ! grep -q "^NODE_ENV=" .env; then
echo "NODE_ENV=development" >> .env
elif ! grep -q "^NODE_ENV=development" .env; then
sed -i 's/^NODE_ENV=.*/NODE_ENV=development/' .env
fi
# Step 1: Run migrations
echo "Step 1: Running database migrations..."
echo "----------------------------------------"
if pnpm db:migrate:up; then
echo "✅ Migrations completed"
else
echo "❌ Migration failed."
echo ""
echo "Common issues:"
echo " 1. Database password is incorrect"
echo " 2. PostgreSQL is not running"
echo " 3. Database 'sankofa' does not exist"
echo ""
echo "To fix:"
echo " 1. Verify PostgreSQL is running: sudo systemctl status postgresql"
echo " 2. Create database if needed: createdb sankofa"
echo " 3. Update .env with correct password"
exit 1
fi
echo ""
# Step 2: Seed Sovereign Stack services
echo "Step 2: Seeding Sovereign Stack services..."
echo "----------------------------------------"
if pnpm db:seed:sovereign-stack; then
echo "✅ Services seeded"
else
echo "❌ Seeding failed. Please check the error above."
exit 1
fi
echo ""
# Step 3: Verify setup
echo "Step 3: Verifying setup..."
echo "----------------------------------------"
if pnpm verify:sovereign-stack; then
echo ""
echo "=========================================="
echo "✅ Sovereign Stack setup complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Access the marketplace at: https://portal.sankofa.nexus/marketplace"
echo "2. Browse Phoenix Cloud Services offerings"
echo "3. Subscribe to services as needed"
echo ""
else
echo "⚠ Verification found issues. Please review the output above."
exit 1
fi

View File

@@ -0,0 +1,141 @@
/**
* Verification script for Sovereign Stack marketplace services
* Verifies that all services are properly registered in the marketplace
*/
import 'dotenv/config'
import { getDb } from '../src/db/index.js'
import { logger } from '../src/lib/logger.js'
async function verifySovereignStackServices() {
const db = getDb()
try {
logger.info('Verifying Sovereign Stack marketplace services...')
// 1. Verify Phoenix publisher exists
const publisherResult = await db.query(
`SELECT * FROM publishers WHERE name = 'phoenix-cloud-services'`
)
if (publisherResult.rows.length === 0) {
throw new Error('Phoenix publisher not found. Please run migration 025 first.')
}
const publisher = publisherResult.rows[0]
logger.info(`✓ Phoenix publisher found: ${publisher.display_name} (${publisher.id})`)
logger.info(` Verified: ${publisher.verified}`)
logger.info(` Website: ${publisher.website_url || 'N/A'}`)
// 2. Verify all 9 services exist
const expectedServices = [
'phoenix-ledger-service',
'phoenix-identity-service',
'phoenix-wallet-registry',
'phoenix-tx-orchestrator',
'phoenix-messaging-orchestrator',
'phoenix-voice-orchestrator',
'phoenix-event-bus',
'phoenix-audit-service',
'phoenix-observability'
]
const servicesResult = await db.query(
`SELECT p.*, pub.display_name as publisher_name
FROM products p
JOIN publishers pub ON p.publisher_id = pub.id
WHERE pub.name = 'phoenix-cloud-services'
ORDER BY p.name`
)
const foundServices = servicesResult.rows.map(row => row.slug)
logger.info(`\n✓ Found ${servicesResult.rows.length} Phoenix services:`)
for (const service of servicesResult.rows) {
logger.info(` - ${service.name} (${service.slug})`)
logger.info(` Category: ${service.category}`)
logger.info(` Status: ${service.status}`)
logger.info(` Featured: ${service.featured}`)
}
// Check for missing services
const missingServices = expectedServices.filter(slug => !foundServices.includes(slug))
if (missingServices.length > 0) {
logger.warn(`\n⚠ Missing services: ${missingServices.join(', ')}`)
logger.warn('Please run: pnpm db:seed:sovereign-stack')
} else {
logger.info(`\n✓ All ${expectedServices.length} expected services found!`)
}
// 3. Verify categories are available
const categoriesResult = await db.query(
`SELECT DISTINCT category FROM products WHERE publisher_id = $1`,
[publisher.id]
)
const categories = categoriesResult.rows.map(row => row.category)
logger.info(`\n✓ Services span ${categories.length} categories:`)
categories.forEach(cat => logger.info(` - ${cat}`))
// 4. Verify product versions exist
const versionsResult = await db.query(
`SELECT COUNT(*) as count
FROM product_versions pv
JOIN products p ON pv.product_id = p.id
JOIN publishers pub ON p.publisher_id = pub.id
WHERE pub.name = 'phoenix-cloud-services'`
)
const versionCount = parseInt(versionsResult.rows[0].count)
logger.info(`\n✓ Found ${versionCount} product versions`)
// 5. Verify pricing models exist
const pricingResult = await db.query(
`SELECT COUNT(*) as count
FROM pricing_models pm
JOIN products p ON pm.product_id = p.id
JOIN publishers pub ON p.publisher_id = pub.id
WHERE pub.name = 'phoenix-cloud-services'`
)
const pricingCount = parseInt(pricingResult.rows[0].count)
logger.info(`✓ Found ${pricingCount} pricing models`)
// 6. Summary
logger.info('\n' + '='.repeat(60))
logger.info('VERIFICATION SUMMARY')
logger.info('='.repeat(60))
logger.info(`Publisher: ${publisher.display_name} (${publisher.verified ? '✓ Verified' : '✗ Not verified'})`)
logger.info(`Services: ${foundServices.length}/${expectedServices.length}`)
logger.info(`Categories: ${categories.length}`)
logger.info(`Versions: ${versionCount}`)
logger.info(`Pricing Models: ${pricingCount}`)
if (missingServices.length === 0 && versionCount >= expectedServices.length && pricingCount >= expectedServices.length) {
logger.info('\n✅ All Sovereign Stack services verified successfully!')
return true
} else {
logger.warn('\n⚠ Some services may need to be seeded. Run: pnpm db:seed:sovereign-stack')
return false
}
} catch (error) {
logger.error('Verification error', { error })
throw error
} finally {
await db.end()
}
}
// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
verifySovereignStackServices()
.then(success => {
process.exit(success ? 0 : 1)
})
.catch((error) => {
logger.error('Failed to verify Sovereign Stack services', { error })
process.exit(1)
})
}
export { verifySovereignStackServices }