A comprehensive Node.js API template with TypeScript, Firebase Functions, Socket.io, and extensive authentication and communication capabilities.
- TypeScript - Full TypeScript support with strict typing
- Express.js - Fast, unopinionated web framework
- MongoDB - NoSQL database with Mongoose ODM
- Firebase Functions - Serverless deployment support
- Socket.io - Real-time bidirectional communication
- Webpack - Module bundling and optimization
-
Multi-Provider Authentication:
- Internal (Database-based) authentication
- Firebase Authentication
- OAuth providers (Google, GitHub, Facebook, Twitter, LinkedIn, Microsoft, Apple, Discord, Spotify, Twitch)
- SMS authentication (Twilio, AWS SNS, Vonage, MessageBird)
- Email authentication (Nodemailer, SendGrid, AWS SES, Mailgun, Postmark)
- LDAP authentication
- SAML authentication
- OAuth2 generic provider
- OpenID Connect
- WebAuthn (FIDO2) authentication
- Social media authentication (Instagram, TikTok, Snapchat, Pinterest, Reddit, Slack, Zoom, Dropbox, Bitbucket, GitLab)
- JWT Tokens - JSON Web Token authentication
- Password Policies - Configurable password requirements
- Rate Limiting - Request throttling and protection
- CORS - Cross-Origin Resource Sharing configuration
- Security Headers - Helmet.js security middleware
- Session Management - Secure session handling
- Multi-factor Authentication - Enhanced security options
-
Email System:
- Multiple email providers (SMTP, SendGrid, AWS SES, Mailgun, Postmark)
- Template engine support (Handlebars)
- Email verification, password reset, login codes
- Custom email providers
-
SMS System:
- Multiple SMS providers (Twilio, AWS SNS, Vonage, MessageBird)
- SMS verification codes
- Custom SMS providers
-
Push Notifications:
- Firebase Cloud Messaging (FCM)
- Cross-platform push notifications
- MongoDB Integration - Native MongoDB support with connection pooling
- Database Seeding - Automated data seeding and management
-
File Storage:
- Local file storage
- AWS S3 integration
- Google Cloud Storage
- Cloudinary integration
- CLI Tools - Command-line interface for development
- Module Generation - Automated module scaffolding
- Endpoint Generation - Quick API endpoint creation
- Database Migration - Schema migration tools
- Backup & Restore - Database backup automation
- Health Checks - Application monitoring endpoints
- Logging - Comprehensive logging system (JSON, colored, file-based)
- External Logging - Sentry, Loggly, Papertrail integration
- Performance Monitoring - Application performance tracking
- New Relic Integration - APM monitoring
- Metrics Collection - Application metrics
- Compression - Response compression
- Caching - Redis integration for caching
-
Payment Processing:
- Stripe integration
- PayPal integration
-
Analytics:
- Google Analytics integration
- Hot Reload - Development server with auto-reload
- Type Checking - TypeScript type validation
- Linting - ESLint code quality checks
- Formatting - Prettier code formatting
- Documentation - Auto-generated API documentation
- Testing - Test database configuration
npm install @diagramers/api
npx diagramers-cli api init my-api-project
cd my-api-project
cp .env.example .env
# Edit .env with your configuration
npm install --legacy-peer-deps
npm run dev
The API supports extensive configuration through environment variables:
NODE_ENV=development
PORT=3000
HOST=localhost
APP_URL=http://localhost:3000
DATABASE_TYPE=mongodb
DATABASE_URL=mongodb://localhost:27017/diagramers
DATABASE_NAME=diagramers
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=1h
AUTH_DEFAULT_PROVIDER=internal
EMAIL_ENABLED=true
EMAIL_PROVIDER=nodemailer
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMS_ENABLED=false
SMS_PROVIDER=twilio
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=+1234567890
-
POST /api/auth/register
- User registration -
POST /api/auth/login
- User login -
POST /api/auth/logout
- User logout -
POST /api/auth/refresh
- Refresh JWT token -
POST /api/auth/forgot-password
- Password reset request -
POST /api/auth/reset-password
- Password reset
-
GET /api/auth/oauth/:provider
- OAuth provider authentication -
GET /api/auth/oauth/:provider/callback
- OAuth callback
-
POST /api/auth/sms/send-code
- Send SMS verification code -
POST /api/auth/sms/verify-code
- Verify SMS code
-
POST /api/auth/email/send-code
- Send email verification code -
POST /api/auth/email/verify-code
- Verify email code
-
GET /api/users
- Get all users -
GET /api/users/:id
- Get user by ID -
PUT /api/users/:id
- Update user -
DELETE /api/users/:id
- Delete user
-
GET /api/email/configs
- Get email configurations -
POST /api/email/configs
- Create email configuration -
PUT /api/email/configs/:id
- Update email configuration -
DELETE /api/email/configs/:id
- Delete email configuration -
POST /api/email/send
- Send email
-
GET /api/notifications
- Get notifications -
POST /api/notifications
- Create notification -
PUT /api/notifications/:id
- Update notification -
DELETE /api/notifications/:id
- Delete notification
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run clean # Clean build artifacts
npm run seed # Seed database
npm run seed:force # Force seed database
npm run seed:reset # Reset and seed database
npm run seed:truncate # Truncate database
npm run generate:module # Generate new module
npm run generate:endpoint # Generate new endpoint
npm run generate:table # Generate database table
npm run generate:relation # Generate database relation
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues
npm run type-check # TypeScript type checking
npm run format # Format code with Prettier
npm run format:check # Check code formatting
npm run docs # Generate documentation
npm run docs:serve # Serve documentation
npm run docker:build # Build Docker image
npm run docker:run # Run Docker container
npm run docker:compose # Start with Docker Compose
npm run docker:compose:down # Stop Docker Compose
npm run backup # Backup database
npm run backup:restore # Restore database backup
npm run migrate # Run database migrations
npm run migrate:create # Create new migration
npm run migrate:rollback # Rollback migration
npm run health # Health check
npm run logs # View application logs
npm run logs:clear # Clear application logs
npm run monitor # Start monitoring
The API supports a plugin system for extending functionality:
src/plugins/
├── base/
│ ├── manager.ts
│ └── plugin.ts
└── registry/
└── auth.plugin.ts
import { BasePlugin } from '../base/plugin';
export class CustomPlugin extends BasePlugin {
async initialize(): Promise<void> {
// Plugin initialization logic
}
async execute(data: any): Promise<any> {
// Plugin execution logic
}
}
TEST_DATABASE_URL=mongodb://localhost:27017/diagramers-api-test
TEST_JWT_SECRET=test-jwt-secret
npm test # Run all tests
npm run test:unit # Run unit tests
npm run test:integration # Run integration tests
npm run test:coverage # Run tests with coverage
npm run deploy # Deploy to Firebase Functions
npm run deploy:staging # Deploy to staging
npm run deploy:production # Deploy to production
npm run docker:build
npm run docker:run
npm run deploy:staging # Deploy to staging environment
npm run deploy:production # Deploy to production environment
LOG_LEVEL=info
LOG_FORMAT=colored
LOG_FILE_ENABLED=true
LOG_FILE_PATH=logs/app.log
- Sentry - Error tracking and monitoring
- Loggly - Log aggregation and analysis
- Papertrail - Log management and search
curl http://localhost:3000/health
- Helmet.js for security headers
- CORS configuration
- Rate limiting
- Input validation
- JWT token management
- Password hashing with bcrypt
- Session management
- Multi-factor authentication
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details
- @diagramers/admin - React admin dashboard template
- @diagramers/cli - Command-line interface for scaffolding
For support and questions:
- Create an issue on GitHub
- Check the documentation
- Review the examples in the codebase
- [ ] GraphQL support
- [ ] Microservices architecture
- [ ] Kubernetes deployment
- [ ] Advanced caching strategies
- [ ] Real-time analytics
- [ ] Advanced security features
- [ ] Multi-tenant support
- [ ] API versioning
- [ ] Advanced rate limiting
- [ ] Webhook system