bagsy/scripts/setup-api.sh
bananabas 88701de549 chore: clean up project structure
- Remove duplicate iOS app folder (ShopList/ → consolidated to Bagsy/)
- Remove build artifacts from git tracking
- Remove stale documentation files
- Remove old React Native mobile code
- Add PROJECT_STATUS.md for clear project overview

iOS app is now clearly organized under apps/ios/Bagsy/ with single Xcode project (Bagsy.xcodeproj)
2026-04-13 17:16:11 +01:00

97 lines
No EOL
2.5 KiB
Bash

#!/bin/bash
# Setup script for Bagsy API with passkey support
# This creates a SQLite database for development
set -e
echo "🛍️ Bagsy API Setup"
echo "=================="
# Check if bun is installed
if ! command -v bun &> /dev/null; then
echo "❌ Bun is required. Install from https://bun.sh"
exit 1
fi
# Install dependencies
echo ""
echo "📦 Installing dependencies..."
cd /Users/barnabasbodily/shop/apps/api
bun install
# Check for database
echo ""
echo "🗄️ Database Setup"
# Check if DATABASE_URL is set
if [ -z "$DATABASE_URL" ]; then
echo "⚠️ No DATABASE_URL found."
echo ""
echo "Options:"
echo "1. Use SQLite (quick dev setup)"
echo "2. Use PostgreSQL (for production/passkeys)"
echo ""
read -p "Choose (1/2): " choice
case $choice in
1)
# Use SQLite
export DATABASE_URL="file:./dev.db"
echo "✅ Using SQLite: $DATABASE_URL"
# Note: better-auth requirespg for passkey - SQLite works for basic auth
echo ""
echo "⚠️ Note: Passkey auth works best with PostgreSQL"
echo " SQLite supports email/password sign-up/sign-in"
;;
2)
echo ""
echo "📋 PostgreSQL Setup Required"
echo ""
echo "Options for PostgreSQL:"
echo " • Neon.tech (free tier) - https://neon.tech"
echo " • Supabase (free tier) - https://supabase.com"
echo " • Railway (\$5/mo) - https://railway.app"
echo " • Local Docker: docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=pass postgres"
echo ""
read -p "Enter PostgreSQL DATABASE_URL: " DATABASE_URL
export DATABASE_URL
;;
esac
fi
# Add to .env.local
echo ""
echo "💾 Saving to .env.local..."
cat > .env.local << EOF
# Database
DATABASE_URL=$DATABASE_URL
# Auth (generate with: openssl rand -base64 32)
BETTER_AUTH_SECRET=$(openssl rand -base64 32)
BETTER_AUTH_URL=http://localhost:3001
# Next.js
NEXT_PUBLIC_APP_URL=http://localhost:3001
NODE_ENV=development
EOF
echo "✅ Configuration saved!"
# Test database connection
echo ""
echo "🧪 Testing database..."
if echo "SELECT 1" | bunx drizzle-kit push 2>/dev/null; then
echo "✅ Database ready!"
else
echo "⚠️ Database setup may need attention"
fi
echo ""
echo "🚀 Starting API server..."
echo " API: http://localhost:3001"
echo " WebSocket: ws://localhost:3001/api/ws"
echo ""
# Start the server
bun run dev