ReactPress Server - NestJS 10 backend API for ReactPress CMS with simple installation.
ReactPress Server is a backend API built with NestJS 10 that powers the ReactPress CMS platform. It provides RESTful APIs for content management, user authentication, media handling, and more. With its simple installation process, it offers a smooth setup experience.
The server is built with a modular architecture following NestJS best practices, making it extensible and maintainable. It automatically generates OpenAPI/Swagger documentation that powers the ReactPress Toolkit.
# Regular startup
npx @fecommunity/reactpress-server
# PM2 startup for production
npx @fecommunity/reactpress-server --pm2That's it! The command will automatically:
- Auto-detect if configuration exists
- Launch installation wizard in your browser if no configuration found
- Start the server immediately after installation
- Open API documentation at
http://localhost:3002/api
- ๐ Simple Installation - No complex CLI parameters needed
- ๐ง Auto-Configuration - Generates
.envfiles automatically - ๐ Database Setup - Creates MySQL database with migrations
- ๐ฏ Seamless Flow - From installation to running server
- ๐ Auto-Documentation - Swagger API docs available immediately
- โก PM2 Support - Optional PM2 process management
- ๐ Security - JWT with refresh token rotation, rate limiting
- ๐ก๏ธ Protection - Helmet.js, CSRF protection, input validation
- ๐ฑ Responsive APIs - Mobile-friendly RESTful endpoints
- ๐ Globalization - Multi-language support
- ๐ Analytics Tracking - Built-in view and visitor analytics
- ๐ Data Synchronization - Scheduled tasks and webhook support
- Node.js >= 18.20.4
- MySQL 8.0+ or PostgreSQL 13+
- npm or pnpm package manager
Perfect for:
- Headless CMS implementation
- Mobile app backend
- Microservices architecture
- Custom frontend integration
- Enterprise API gateway
Use with ReactPress client for complete CMS solution:
# Start server
npx @fecommunity/reactpress-server
# In another terminal, start client
npx @fecommunity/reactpress-clientReactPress Server provides comprehensive API modules:
- Article Management - Create, read, update, delete articles with versioning
- User Authentication - Registration, login, password management, 2FA
- Comment System - Comment moderation and management with spam detection
- Media Management - File upload and management (local/S3/Cloudinary)
- Category & Tag - Content organization systems with hierarchy
- Page Management - Custom page creation with templates
- Settings - System configuration management with environment overrides
- SMTP - Email sending capabilities with template system
- Search - Full-text search functionality with Elasticsearch integration
- Analytics - Visitor and view tracking with export capabilities
- Webhooks - Event-driven integrations with external services
- Scheduled Tasks - Cron jobs for automated operations
ReactPress server supports PM2 process management for production deployments:
# Start with PM2
npx @fecommunity/reactpress-server --pm2PM2 features:
- Automatic process restart on crash
- Memory monitoring
- Log management with rotation
- Process management
- Health checks
The installation wizard will create a .env file with:
# Database Configuration (Production)
DB_HOST=prod-db.cluster-xyz.amazonaws.com
DB_PORT=3306
DB_USER=reactpress_user
DB_PASSWD=secure_password_here
DB_DATABASE=reactpress_prod
DB_SSL=true
# Site URLs (Production)
CLIENT_SITE_URL=https://yourdomain.com
SERVER_SITE_URL=https://api.yourdomain.com
# Security Settings (Production)
JWT_SECRET=your-very-secure-jwt-secret-here
JWT_EXPIRES_IN=24h
JWT_REFRESH_EXPIRES_IN=7d
# SMTP Configuration (Production)
SMTP_HOST=email-smtp.us-east-1.amazonaws.com
SMTP_PORT=587
SMTP_USER=your_smtp_username
SMTP_PASS=your_smtp_password
SMTP_FROM=noreply@yourdomain.com
# Cloud Storage (Optional)
S3_ACCESS_KEY_ID=your_aws_access_key
S3_SECRET_ACCESS_KEY=your_aws_secret_key
S3_BUCKET_NAME=your_bucket_name
S3_REGION=us-east-1Once running, visit http://localhost:3002/api for:
- Interactive Swagger documentation
- API endpoint explorer
- Authentication examples
- Response schemas
- Request/response validation
- Code generation for multiple languages
# Clone repository
git clone https://github.com/fecommunity/reactpress.git
cd reactpress/server
# Install dependencies
pnpm install
# Start development server with hot reload
pnpm run dev
# Start with PM2 (development)
pnpm run pm2:start
# Build for production
pnpm run build
# Run tests
pnpm run test
# Run tests with coverage
pnpm run test:cov
# Run end-to-end tests
pnpm run test:e2eserver/
โโโ src/
โ โโโ modules/ # Feature modules
โ โ โโโ article/ # Article management
โ โ โโโ auth/ # Authentication
โ โ โโโ user/ # User management
โ โ โโโ ... # Other modules
โ โโโ common/ # Shared utilities and decorators
โ โโโ filters/ # Exception filters
โ โโโ interceptors/ # Request/response interceptors
โ โโโ guards/ # Authentication guards
โ โโโ pipes/ # Data transformation pipes
โ โโโ logger/ # Logging utilities
โ โโโ utils/ # Utility functions
โโโ public/ # Static assets
โ โโโ swagger/ # Swagger documentation
โโโ dist/ # Compiled output
โโโ bin/ # CLI entry points
| Variable | Description | Default |
|---|---|---|
DB_HOST |
Database host | 127.0.0.1 |
DB_PORT |
Database port | 3306 |
DB_USER |
Database username | - |
DB_PASSWD |
Database password | - |
DB_DATABASE |
Database name | reactpress |
SERVER_PORT |
Server port | 3002 |
JWT_SECRET |
JWT secret key | - |
CLIENT_SITE_URL |
Client site URL | http://localhost:3001 |
SERVER_SITE_URL |
Server site URL | http://localhost:3002 |
SMTP_HOST |
SMTP server host | - |
SMTP_PORT |
SMTP server port | - |
SMTP_USER |
SMTP username | - |
SMTP_PASS |
SMTP password | - |
# Show help
npx @fecommunity/reactpress-server --help
# Start server
npx @fecommunity/reactpress-server
# Start with PM2
npx @fecommunity/reactpress-server --pm2
# Specify port
npx @fecommunity/reactpress-server --port 3002
# Enable verbose logging
npx @fecommunity/reactpress-server --verbose
# Run database migrations
npx @fecommunity/reactpress-server --migrate
# Seed database with sample data
npx @fecommunity/reactpress-server --seedThe server automatically generates the OpenAPI specification that powers the ReactPress Toolkit:
// The toolkit is automatically generated from this server's API
import { api, types } from '@fecommunity/reactpress-toolkit';
// All API endpoints are strongly typed
const articles: types.IArticle[] = await api.article.findAll();ReactPress uses MySQL/PostgreSQL with the following key tables:
users- User accounts and profiles with 2FA supportarticles- Blog posts and content with versioningcategories- Content categorization with hierarchytags- Content tagging systemcomments- Reader comments and discussions with moderationfiles- Media file managementsettings- System configuration with environment overridesviews- Analytics and trackingwebhooks- Event-driven integrationsscheduled_tasks- Automated operations
- JWT Authentication - Secure token-based authentication with refresh rotation
- Rate Limiting - Adaptive throttling to prevent abuse
- Input Validation - Sanitize all user inputs with Zod schema validation
- Helmet.js - Secure HTTP headers
- CSRF Protection - Prevent cross-site request forgery
- SQL Injection Prevention - Through TypeORM parameterized queries
- CORS Configuration - Controlled cross-origin resource sharing
- Data Encryption - At-rest encryption for sensitive data
- Audit Logging - Comprehensive activity tracking
- Database Indexing - Optimized queries with proper indexing
- Connection Pooling - Efficient database connection management
- Caching - Redis integration for frequently accessed data
- Compression - Gzip compression for API responses
- Pagination - Efficient data retrieval for large datasets
- Query Optimization - TypeORM query builder for complex operations
- Background Jobs - Queue system for long-running tasks
# Run unit tests
pnpm run test
# Run integration tests
pnpm run test:integration
# Run end-to-end tests
pnpm run test:e2e
# Run tests with coverage
pnpm run test:cov
# Run linting
pnpm run lint
# Run formatting
pnpm run format
# Run type checking
pnpm run type-check# Start server with PM2
npx @fecommunity/reactpress-server --pm2
# Or build and start manually
pnpm run build
pnpm run start:prod
- Structured Logging - JSON-formatted logs for easy parsing
- Error Tracking - Comprehensive error reporting with context
- Performance Metrics - Response time and throughput monitoring
- Health Checks - API endpoint for service status
- Alerting - Basic alerting capabilities
- ๐ Documentation
- ๐ Issues
- ๐ฌ Discussions
- ๐ง Support
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a pull request
MIT License - see LICENSE file for details.
Built with โค๏ธ by FECommunity