{"id":28898837,"url":"https://github.com/dlato97/fastify-auth-boilerplate","last_synced_at":"2026-04-30T16:34:17.597Z","repository":{"id":295864863,"uuid":"989645084","full_name":"dlato97/fastify-auth-boilerplate","owner":"dlato97","description":"Modern Fastify backend boilerplate with authentication and RBAC made with prisma, PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-05-28T06:57:36.000Z","size":154,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T16:34:05.674Z","etag":null,"topics":["fastify","postgresql","prisma","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dlato97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T14:27:18.000Z","updated_at":"2025-07-14T10:56:54.000Z","dependencies_parsed_at":"2025-05-27T19:37:48.328Z","dependency_job_id":"91da99c8-1c2f-4a63-94d8-8457c4f5cb7f","html_url":"https://github.com/dlato97/fastify-auth-boilerplate","commit_stats":null,"previous_names":["dlato97/fastify-auth-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dlato97/fastify-auth-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlato97%2Ffastify-auth-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlato97%2Ffastify-auth-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlato97%2Ffastify-auth-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlato97%2Ffastify-auth-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlato97","download_url":"https://codeload.github.com/dlato97/fastify-auth-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlato97%2Ffastify-auth-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32470879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify","postgresql","prisma","typescript"],"created_at":"2025-06-21T08:00:29.819Z","updated_at":"2026-04-30T16:34:17.592Z","avatar_url":"https://github.com/dlato97.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Fastify Auth Boilerplate - Installation Guide\n\n## Prerequisites\n\n- **Node.js 20+** (LTS recommended)\n- **Docker \u0026 Docker Compose** (for local development)\n- **Git** (for version control)\n\n## Quick Start (Automated Setup)\n\n```bash\n# 1. Clone the repository\ngit clone \u003cyour-repository-url\u003e\ncd fastify-auth-boilerplate\n\n# 2. Make setup script executable\nchmod +x scripts/setup.sh\n\n# 3. Run automated setup\n./scripts/setup.sh\n```\n\nThe script will:\n- Install dependencies\n- Setup environment variables\n- Start Docker services\n- Run database migrations\n- Seed initial data\n- Create admin user\n\n## Manual Setup\n\n### 1. Install Dependencies\n\n```bash\nnpm install\n```\n\n### 2. Environment Configuration\n\n```bash\n# Copy environment template\ncp .env.example .env\n\n# Edit environment variables\nnano .env\n```\n\n**Important:** Generate secure secrets for JWT tokens:\n\n```bash\n# Generate JWT secrets (Linux/macOS)\nopenssl rand -hex 32\n\n# Or use Node.js\nnode -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"\n```\n\n### 3. Start Services\n\n```bash\n# Start PostgreSQL, Redis, MailHog, Adminer\ndocker-compose up -d\n\n# Verify services are running\ndocker-compose ps\n```\n\n### 4. Database Setup\n\n```bash\n# Generate Prisma client\nnpm run db:generate\n\n# Run migrations\nnpm run db:migrate\n\n# Seed database with initial data\nnpm run db:seed\n```\n\n### 5. Start Development Server\n\n```bash\n# Start in development mode\nnpm run dev\n\n# Or build and start production\nnpm run build\nnpm start\n```\n\n## Available Services\n\n| Service | URL | Description |\n|---------|-----|-------------|\n| **API Server** | http://localhost:3000 | Main API server |\n| **API Documentation** | http://localhost:3000/documentation | Swagger UI |\n| **Health Check** | http://localhost:3000/health | Server health status |\n| **Prisma Studio** | http://localhost:5555 | Database GUI |\n| **MailHog** | http://localhost:8025 | Email testing |\n| **Adminer** | http://localhost:8080 | Database admin |\n\n## Default Accounts\n\nAfter seeding, these accounts are available:\n\n| Role | Email | Password | Permissions |\n|------|-------|----------|-------------|\n| **Super Admin** | admin@example.com | Admin123!@# | Full system access |\n| **Moderator** | moderator@example.com | Moderator123! | User management |\n| **User** | user@example.com | User123! | Standard access |\n\n\u003e ⚠️ **Security**: Change all default passwords before production deployment!\n\n## API Endpoints\n\n### Authentication\n\n```bash\n# Register new user\nPOST /api/v1/auth/register\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"SecurePass123!\",\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\"\n}\n\n# Login\nPOST /api/v1/auth/login\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"SecurePass123!\"\n}\n\n# Get profile (requires auth)\nGET /api/v1/auth/me\nAuthorization: Bearer \u003ctoken\u003e\n\n# Enable 2FA\nPOST /api/v1/auth/2fa/setup\nAuthorization: Bearer \u003ctoken\u003e\n{\n  \"password\": \"current-password\"\n}\n```\n\n### User Management (Admin only)\n\n```bash\n# Get users list\nGET /api/v1/users?page=1\u0026limit=20\nAuthorization: Bearer \u003cadmin-token\u003e\n\n# Create user\nPOST /api/v1/users\nAuthorization: Bearer \u003cadmin-token\u003e\n{\n  \"email\": \"newuser@example.com\",\n  \"password\": \"SecurePass123!\",\n  \"roles\": [\"user\"]\n}\n```\n\n## Development Commands\n\n### Database\n\n```bash\nnpm run db:generate     # Generate Prisma client\nnpm run db:push         # Push schema changes (dev)\nnpm run db:migrate      # Create and run migrations\nnpm run db:studio       # Open Prisma Studio\nnpm run db:seed         # Seed database\nnpm run db:reset        # Reset database\n```\n\n### Development\n\n```bash\nnpm run dev            # Start development server\nnpm run build          # Build for production\nnpm run start          # Start production server\nnpm run type-check     # TypeScript check only\n```\n\n### Code Quality\n\n```bash\nnpm run lint           # Lint code\nnpm run lint:fix       # Fix linting issues\nnpm run format         # Format code with Prettier\n```\n\n### Testing\n\n```bash\nnpm run test           # Run tests\nnpm run test:ui        # Open test UI\nnpm run test:coverage  # Run with coverage\n```\n\n### Docker\n\n```bash\nnpm run docker:up      # Start all services\nnpm run docker:down    # Stop all services\nnpm run docker:logs    # View logs\n```\n\n## Environment Variables\n\n### Required Variables\n\n```bash\n# Database\nDATABASE_URL=\"postgresql://postgres:postgres@localhost:5432/fastify_auth\"\n\n# Redis\nREDIS_URL=\"redis://:redis123@localhost:6379\"\n\n# JWT Secrets (MUST BE CHANGED)\nJWT_ACCESS_SECRET=\"your-32-char-secret-here\"\nJWT_REFRESH_SECRET=\"your-32-char-secret-here\"\nSESSION_SECRET=\"your-32-char-secret-here\"\n```\n\n### Optional Variables\n\n```bash\n# Server\nNODE_ENV=\"development\"\nPORT=3000\nHOST=\"localhost\"\n\n# Email (MailHog for development)\nSMTP_HOST=\"localhost\"\nSMTP_PORT=1025\nSMTP_FROM=\"noreply@yourapp.com\"\n\n# Features\nENABLE_2FA=true\nENABLE_EMAIL_VERIFICATION=true\nSWAGGER_ENABLED=true\n```\n\n## Production Deployment\n\n### 1. Environment Setup\n\n```bash\n# Production environment variables\nNODE_ENV=production\nDATABASE_URL=\"postgresql://user:pass@prod-host:5432/dbname\"\nREDIS_URL=\"redis://user:pass@prod-host:6379\"\n\n# Use strong, unique secrets\nJWT_ACCESS_SECRET=\"production-secret-32-chars-min\"\nJWT_REFRESH_SECRET=\"production-secret-32-chars-min\"\nSESSION_SECRET=\"production-secret-32-chars-min\"\n\n# Production email service\nSMTP_HOST=\"smtp.sendgrid.net\"\nSMTP_PORT=587\nSMTP_USER=\"apikey\"\nSMTP_PASS=\"your-sendgrid-api-key\"\n```\n\n### 2. Build and Deploy\n\n```bash\n# Build application\nnpm run build\n\n# Start production server\nnpm start\n\n# Or use PM2 for process management\nnpm install -g pm2\npm2 start dist/index.js --name \"fastify-auth\"\n```\n\n### 3. Docker Production\n\n```dockerfile\n# Build production image\ndocker build -t fastify-auth .\n\n# Run container\ndocker run -p 3000:3000 \\\n  -e NODE_ENV=production \\\n  -e DATABASE_URL=\"...\" \\\n  -e JWT_ACCESS_SECRET=\"...\" \\\n  fastify-auth\n```\n\n## Troubleshooting\n\n### Common Issues\n\n**Port already in use:**\n```bash\n# Check what's using the port\nlsof -i :3000\n# Kill the process\nkill -9 \u003cPID\u003e\n```\n\n**Database connection failed:**\n```bash\n# Check if PostgreSQL is running\ndocker-compose ps postgres\n# Check logs\ndocker-compose logs postgres\n```\n\n**Redis connection failed:**\n```bash\n# Check Redis status\ndocker-compose ps redis\n# Test connection\nredis-cli -h localhost -p 6379 ping\n```\n\n**Prisma client issues:**\n```bash\n# Regenerate client\nnpm run db:generate\n# Reset database\nnpm run db:reset\n```\n\n### Debugging\n\nEnable debug logging:\n```bash\n# In .env file\nLOG_LEVEL=\"debug\"\nENABLE_REQUEST_LOGGING=true\n```\n\nView detailed logs:\n```bash\n# Application logs\nnpm run dev\n\n# Docker service logs\nnpm run docker:logs\n\n# Specific service logs\ndocker-compose logs -f postgres\ndocker-compose logs -f redis\n```\n\n## Security Checklist\n\n- [ ] Change all default passwords\n- [ ] Use strong JWT secrets (32+ characters)\n- [ ] Enable HTTPS in production\n- [ ] Configure proper CORS origins\n- [ ] Set up rate limiting\n- [ ] Enable audit logging\n- [ ] Configure email verification\n- [ ] Set up 2FA for admin accounts\n- [ ] Regular security updates\n- [ ] Monitor for suspicious activity\n\n## Support\n\n- **Documentation**: Check the README.md and code comments\n- **Issues**: Create issues in the repository\n- **Security**: Report security issues privately\n\n---\n\nHappy coding! 🎉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlato97%2Ffastify-auth-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlato97%2Ffastify-auth-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlato97%2Ffastify-auth-boilerplate/lists"}