-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·78 lines (64 loc) · 2.14 KB
/
setup.sh
File metadata and controls
executable file
·78 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# ScribeBoard API Setup Script
echo "📝 ScribeBoard API - Setup Script"
echo "=================================="
echo ""
# Check Node.js
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed. Please install Node.js 18+ first."
exit 1
fi
echo "✅ Node.js $(node -v) detected"
# Check PostgreSQL
if ! command -v psql &> /dev/null; then
echo "⚠️ PostgreSQL CLI not found. Make sure PostgreSQL is running."
fi
# Install dependencies
echo ""
echo "📦 Installing dependencies..."
npm install
# Create .env file
if [ ! -f .env ]; then
echo ""
echo "📄 Creating .env file..."
cp env.example .env
# Generate secrets
ACCESS_SECRET=$(openssl rand -base64 32 2>/dev/null || echo "scribeboard-access-secret-$(date +%s)")
REFRESH_SECRET=$(openssl rand -base64 32 2>/dev/null || echo "scribeboard-refresh-secret-$(date +%s)")
# Update .env with generated secrets
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|your-super-secret-access-key-min-32-characters|$ACCESS_SECRET|g" .env
sed -i '' "s|your-super-secret-refresh-key-min-32-characters|$REFRESH_SECRET|g" .env
else
sed -i "s|your-super-secret-access-key-min-32-characters|$ACCESS_SECRET|g" .env
sed -i "s|your-super-secret-refresh-key-min-32-characters|$REFRESH_SECRET|g" .env
fi
echo "✅ .env file created with generated secrets"
echo ""
echo "⚠️ Please update DATABASE_URL in .env with your PostgreSQL credentials"
else
echo "✅ .env file already exists"
fi
# Generate Prisma client
echo ""
echo "🔧 Generating Prisma client..."
npx prisma generate
# Push database schema
echo ""
echo "📊 Pushing database schema..."
npx prisma db push
# Seed database
echo ""
echo "🌱 Seeding database..."
npm run db:seed
echo ""
echo "✅ Setup complete!"
echo ""
echo "To start the server:"
echo " npm run dev (development with hot reload)"
echo " npm start (production)"
echo ""
echo "Test Accounts:"
echo " admin@scribeboard.com / Admin@123 (Admin)"
echo " editor@scribeboard.com / Admin@123 (Editor)"
echo " author@scribeboard.com / Admin@123 (Author)"