A collection of complete, production-ready examples built with MoroJS. Each example demonstrates different aspects of the framework and provides a solid foundation for building real-world applications.
Perfect for beginners
- Basic REST API setup
- Route handlers and middleware
- Request validation with Zod
- Simple in-memory data storage
Use when: Learning MoroJS basics or building simple APIs
Basic authentication with OAuth providers
- GitHub and Google OAuth integration
- JWT-based session management
- Protected route examples
- Demo mode for testing without OAuth setup
- Programmatic sign in/out APIs
Use when: Adding basic authentication to your app
Production-ready enterprise system
- Modular architecture with dependency injection
- Multi-module organization (users, orders, products)
- JWT authentication with role-based access control
- Database integration with PostgreSQL
- Comprehensive validation and error handling
- Event-driven communication between modules
Use when: Building large-scale business applications
Advanced authentication with RBAC and enterprise features
- Role-Based Access Control (Admin, Manager, User)
- Multiple OAuth providers (GitHub, Google, Microsoft, Okta)
- Permission-based authorization system
- Security audit logging and event tracking
- Enterprise SSO integration (Azure AD, Okta)
- Advanced session management with security features
- Webhook security with API key authentication
Use when: Building enterprise applications with complex security requirements
WebSocket-powered real-time application
- WebSocket integration for instant messaging
- User authentication and presence tracking
- Room-based chat system
- Typing indicators and read receipts
- Message persistence with PostgreSQL
- Redis for session management
Use when: Building real-time features like chat, notifications, or live updates
π E-commerce API
Complete online store backend
- Product catalog with search and filtering
- Shopping cart management
- Stripe payment integration
- Order processing and tracking
- Inventory management
- Admin dashboard endpoints
Use when: Building e-commerce platforms or payment-enabled applications
Distributed system architecture
- Multiple interconnected services
- Docker containerization
- Service discovery and communication
- API Gateway pattern
- Inter-service events and messaging
- Kubernetes deployment configs
Use when: Building scalable distributed systems
Comprehensive framework features
- Advanced caching strategies
- File upload handling
- Rate limiting and security
- Database optimization
- Custom middleware examples
- Performance monitoring
Use when: Exploring advanced MoroJS capabilities
Multi-runtime deployment
- Node.js traditional deployment
- Vercel Edge Functions
- AWS Lambda serverless
- Cloudflare Workers
- Runtime adapter examples
Use when: Deploying to different hosting platforms
Event-driven architecture
- Complex event sourcing patterns
- Message queues and processing
- Saga pattern implementation
- Event replay and debugging
- Cross-service communication
Use when: Building event-driven systems
Choose an example based on your needs:
# Clone the repository
git clone https://github.com/Moro-JS/examples.git
cd examples
# Choose and run an example
cd simple-api
npm install
npm run devFor beginners:
- Start with Simple API to learn basics
- Move to Feature Showcase for advanced concepts
- Try Real-time Chat for WebSocket features
For production apps:
- Study Enterprise Application for architecture patterns
- Explore E-commerce API for payment integration
- Review Microservices for scaling strategies
For specific use cases:
- Real-time features: Real-time Chat
- Payment processing: E-commerce API
- Distributed systems: Microservices
- Event-driven: Enterprise Events
- Multi-runtime: Runtime Examples
All examples showcase different combinations of:
- Framework: MoroJS with TypeScript
- Databases: PostgreSQL, Redis, SQLite
- Authentication: JWT, OAuth2, API Keys
- Payments: Stripe, PayPal
- Real-time: WebSockets, Server-Sent Events
- Caching: Redis, in-memory
- Validation: Zod schemas
- Testing: Jest, Supertest
- Deployment: Docker, Kubernetes, Serverless
Each example includes:
example-name/
βββ src/ # Source code
βββ tests/ # Test files
βββ database/ # Schema and migrations
βββ docs/ # Additional documentation
βββ package.json # Dependencies and scripts
βββ README.md # Example-specific guide
βββ .env.example # Environment template
βββ docker-compose.yml # Local development (if applicable)
βββ Dockerfile # Production deployment (if applicable)
# Clone the repository
git clone https://github.com/Moro-JS/examples.git
cd examples
# Install dependencies for all examples (uses @morojs/moro from npm)
npm run setup:npm
# Run a specific example
cd simple-api
npm run dev- Node.js 18+
- PostgreSQL 14+ (for database examples)
- Redis 6+ (for caching examples)
- Docker (for containerized examples)
This repository supports two modes:
- NPM Mode (default): Uses
@morojs/morofrom npm - perfect for trying examples - Local Mode: Uses local framework files - perfect for framework development
# Switch to NPM mode (GitHub ready)
npm run setup:npm
# Switch to Local mode (framework development)
npm run setup:localSee DEVELOPMENT.md for detailed setup instructions.
# Install dependencies
npm install
# Development server
npm run dev
# Production build
npm run build
npm start
# Run tests
npm test
# Database setup (if applicable)
npm run db:setup
npm run db:migrate
npm run db:seedMost examples use environment variables for configuration:
# Copy example environment file
cp .env.example .env
# Edit with your settings
nano .envCommon environment variables:
DATABASE_URL- PostgreSQL connection stringREDIS_URL- Redis connection stringJWT_SECRET- Secret for JWT token signingSTRIPE_SECRET_KEY- Stripe API key (for payment examples)PORT- Server port (default: 3000)
Run tests for all examples:
# Install dependencies for all examples
npm run install:all
# Run all tests
npm run test:all
# Run specific example tests
cd simple-api && npm test- MoroJS Documentation - Framework documentation
- API Reference - Complete API reference
- Deployment Guide - Production deployment
- Best Practices - Recommended patterns
We welcome contributions! Here's how to help:
- Report Issues: Found a bug? Create an issue
- Suggest Examples: Need an example for your use case? Let us know!
- Improve Examples: Submit PRs to enhance existing examples
- Add Examples: Contribute new examples following our structure
- Fork this repository
- Create a new directory with your example
- Follow the standard structure (see above)
- Include comprehensive README and tests
- Submit a pull request
MIT License - see LICENSE file for details.
- Documentation: https://morojs.com
- GitHub Issues: Report bugs or request features
- Discord: Join our community
- Twitter: @MoroJS
Built with β€οΈ by the MoroJS team and community.