@fecommunity/reactpress-server 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +281 -309
- package/bin/reactpress-server.js +173 -414
- package/dist/generate-swagger.d.ts +1 -0
- package/dist/generate-swagger.js +73 -0
- package/dist/generate-swagger.js.map +1 -0
- package/dist/main.d.ts +5 -0
- package/dist/main.js +258 -39
- package/dist/main.js.map +1 -1
- package/dist/modules/setting/setting.service.js +34 -11
- package/dist/modules/setting/setting.service.js.map +1 -1
- package/dist/public/favicon.png +0 -0
- package/dist/public/index.html +439 -0
- package/dist/public/swagger/custom.css +11 -0
- package/dist/starter.d.ts +1 -0
- package/dist/starter.js +84 -0
- package/dist/starter.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +687 -60
- package/package.json +34 -25
- package/public/favicon.png +0 -0
- package/public/index.html +439 -0
- package/public/swagger/custom.css +11 -0
- package/dist/bootstrap.d.ts +0 -10
- package/dist/bootstrap.js +0 -57
- package/dist/bootstrap.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,395 +1,367 @@
|
|
|
1
1
|
# @fecommunity/reactpress-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ReactPress Server - Enterprise-grade NestJS 10 backend API for ReactPress CMS with WordPress-style 5-minute installation.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@fecommunity/reactpress-server)
|
|
6
|
+
[](https://github.com/fecommunity/reactpress/blob/master/server/LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](http://www.typescriptlang.org/)
|
|
9
|
+
[](https://nestjs.com/)
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
# For new projects
|
|
9
|
-
npm install @fecommunity/reactpress-server@1.0.0-beta.1 @fecommunity/reactpress-config@1.0.0-beta.1
|
|
10
|
-
|
|
11
|
-
# Using yarn
|
|
12
|
-
yarn add @fecommunity/reactpress-server@1.0.0-beta.1 @fecommunity/reactpress-config@1.0.0-beta.1
|
|
13
|
-
|
|
14
|
-
# Using pnpm in workspace root (add -w flag)
|
|
15
|
-
pnpm add -w @fecommunity/reactpress-server@1.0.0-beta.1 @fecommunity/reactpress-config@1.0.0-beta.1
|
|
16
|
-
|
|
17
|
-
# Using pnpm in standalone project
|
|
18
|
-
pnpm add @fecommunity/reactpress-server@1.0.0-beta.1 @fecommunity/reactpress-config@1.0.0-beta.1
|
|
19
|
-
```
|
|
11
|
+
## Overview
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
ReactPress Server is an enterprise-grade, production-ready backend API built with NestJS 10 that powers the ReactPress CMS platform. It provides a comprehensive set of RESTful APIs for content management, user authentication, media handling, and more. With its WordPress-style 5-minute installation, it offers an incredibly smooth setup experience.
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
- 🔐 **Authentication & Authorization** - JWT-based auth with role management
|
|
25
|
-
- 📝 **Content Management** - Full CRUD for articles, categories, tags, and comments
|
|
26
|
-
- 🗃️ **Database Integration** - MySQL support with TypeORM
|
|
27
|
-
- 📁 **File Upload** - Local and cloud storage support (Ali OSS)
|
|
28
|
-
- 🌍 **Internationalization** - Multi-language support
|
|
29
|
-
- 📚 **API Documentation** - Auto-generated Swagger docs
|
|
30
|
-
- 🔒 **Security** - Rate limiting, CORS, Helmet integration
|
|
15
|
+
The server is built with a modular architecture following NestJS best practices, making it highly extensible and maintainable. It automatically generates OpenAPI/Swagger documentation that powers the [ReactPress Toolkit](../toolkit), ensuring seamless frontend-backend integration.
|
|
31
16
|
|
|
32
17
|
## Quick Start
|
|
33
18
|
|
|
34
|
-
###
|
|
19
|
+
### Installation & Setup
|
|
35
20
|
|
|
36
21
|
```bash
|
|
37
|
-
#
|
|
38
|
-
npx @fecommunity/reactpress-server
|
|
22
|
+
# Regular startup
|
|
23
|
+
npx @fecommunity/reactpress-server
|
|
39
24
|
|
|
40
|
-
#
|
|
41
|
-
reactpress-server
|
|
25
|
+
# PM2 startup for production
|
|
26
|
+
npx @fecommunity/reactpress-server --pm2
|
|
42
27
|
```
|
|
43
28
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
That's it! The command will automatically:
|
|
30
|
+
|
|
31
|
+
1. **Auto-detect** if configuration exists
|
|
32
|
+
2. **Launch installation wizard** in your browser if no configuration found
|
|
33
|
+
3. **Start the server** immediately after installation
|
|
34
|
+
4. **Open API documentation** at `http://localhost:3002/api`
|
|
35
|
+
|
|
36
|
+
## Enterprise Features
|
|
37
|
+
|
|
38
|
+
- 🚀 **Zero-Command Installation** - No complex CLI parameters needed
|
|
39
|
+
- 🌍 **WordPress-Style Setup** - Familiar 5-minute installation process
|
|
40
|
+
- 🔧 **Auto-Configuration** - Generates `.env` files automatically
|
|
41
|
+
- 🔌 **Database Auto-Provisioning** - Creates MySQL database with migrations
|
|
42
|
+
- 🎯 **Seamless Flow** - From installation to running server in minutes
|
|
43
|
+
- 📖 **Auto-Documentation** - Swagger API docs available immediately
|
|
44
|
+
- ⚡ **PM2 Support** - Optional PM2 process management for production
|
|
45
|
+
- 🔐 **Enterprise Security** - JWT with refresh token rotation, rate limiting
|
|
46
|
+
- 🛡️ **Advanced Security** - Helmet.js, CSRF protection, input validation
|
|
47
|
+
- 📱 **Responsive APIs** - Mobile-friendly RESTful endpoints
|
|
48
|
+
- 🌐 **Globalization** - Multi-language support with RTL
|
|
49
|
+
- 📊 **Analytics Tracking** - Built-in view and visitor analytics
|
|
50
|
+
- 🔄 **Data Synchronization** - Scheduled tasks and webhook support
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- Node.js >= 18.20.4
|
|
55
|
+
- MySQL 8.0+ or PostgreSQL 13+
|
|
56
|
+
- npm or pnpm package manager
|
|
57
|
+
|
|
58
|
+
## Usage Scenarios
|
|
59
|
+
|
|
60
|
+
### Standalone API Server
|
|
61
|
+
Perfect for:
|
|
62
|
+
- Headless CMS implementation
|
|
63
|
+
- Mobile app backend
|
|
64
|
+
- Microservices architecture
|
|
65
|
+
- Custom frontend integration
|
|
66
|
+
- Enterprise API gateway
|
|
67
|
+
|
|
68
|
+
### Full ReactPress Stack
|
|
69
|
+
Use with ReactPress client for complete CMS solution:
|
|
48
70
|
```bash
|
|
49
|
-
#
|
|
50
|
-
npx @fecommunity/reactpress-server
|
|
71
|
+
# Start server
|
|
72
|
+
npx @fecommunity/reactpress-server
|
|
51
73
|
|
|
52
|
-
#
|
|
53
|
-
reactpress-
|
|
74
|
+
# In another terminal, start client
|
|
75
|
+
npx @fecommunity/reactpress-client
|
|
54
76
|
```
|
|
55
77
|
|
|
56
|
-
|
|
78
|
+
## API Modules
|
|
57
79
|
|
|
58
|
-
|
|
80
|
+
ReactPress Server provides comprehensive enterprise API modules:
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
82
|
+
- **Article Management** - Create, read, update, delete articles with versioning
|
|
83
|
+
- **User Authentication** - Registration, login, password management, 2FA
|
|
84
|
+
- **Comment System** - Comment moderation and management with spam detection
|
|
85
|
+
- **Media Management** - File upload and management (local/S3/Cloudinary)
|
|
86
|
+
- **Category & Tag** - Content organization systems with hierarchy
|
|
87
|
+
- **Page Management** - Custom page creation with templates
|
|
88
|
+
- **Settings** - System configuration management with environment overrides
|
|
89
|
+
- **SMTP** - Email sending capabilities with template system
|
|
90
|
+
- **Search** - Full-text search functionality with Elasticsearch integration
|
|
91
|
+
- **Analytics** - Visitor and view tracking with export capabilities
|
|
92
|
+
- **Webhooks** - Event-driven integrations with external services
|
|
93
|
+
- **Scheduled Tasks** - Cron jobs for automated operations
|
|
63
94
|
|
|
64
|
-
|
|
65
|
-
reactpress-server start
|
|
66
|
-
```
|
|
95
|
+
## PM2 Support
|
|
67
96
|
|
|
68
|
-
|
|
97
|
+
ReactPress server supports PM2 process management for production deployments:
|
|
69
98
|
|
|
70
|
-
The package includes a powerful CLI for server management:
|
|
71
|
-
|
|
72
|
-
### Initialize Project
|
|
73
99
|
```bash
|
|
74
|
-
#
|
|
75
|
-
npx @fecommunity/reactpress-server
|
|
76
|
-
|
|
77
|
-
# Or if installed globally
|
|
78
|
-
reactpress-server init [options]
|
|
79
|
-
|
|
80
|
-
Options:
|
|
81
|
-
-p, --port <port> Server port (default: 3002)
|
|
82
|
-
--api-prefix <prefix> API prefix (default: /api)
|
|
83
|
-
--db-host <host> Database host (default: localhost)
|
|
84
|
-
--db-port <port> Database port (default: 3306)
|
|
85
|
-
--db-name <name> Database name (default: reactpress)
|
|
100
|
+
# Start with PM2
|
|
101
|
+
npx @fecommunity/reactpress-server --pm2
|
|
86
102
|
```
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
PM2 features:
|
|
105
|
+
- Automatic process restart on crash
|
|
106
|
+
- Memory monitoring and alerts
|
|
107
|
+
- Log management with rotation
|
|
108
|
+
- Cluster mode support for horizontal scaling
|
|
109
|
+
- Process monitoring dashboard with health checks
|
|
92
110
|
|
|
93
|
-
|
|
94
|
-
reactpress-server dev [options]
|
|
111
|
+
## Configuration
|
|
95
112
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
The installation wizard will create a `.env` file with:
|
|
114
|
+
|
|
115
|
+
```env
|
|
116
|
+
# Database Configuration (Production)
|
|
117
|
+
DB_HOST=prod-db.cluster-xyz.amazonaws.com
|
|
118
|
+
DB_PORT=3306
|
|
119
|
+
DB_USER=reactpress_user
|
|
120
|
+
DB_PASSWD=secure_password_here
|
|
121
|
+
DB_DATABASE=reactpress_prod
|
|
122
|
+
DB_SSL=true
|
|
123
|
+
|
|
124
|
+
# Site URLs (Production)
|
|
125
|
+
CLIENT_SITE_URL=https://yourdomain.com
|
|
126
|
+
SERVER_SITE_URL=https://api.yourdomain.com
|
|
127
|
+
|
|
128
|
+
# Security Settings (Production)
|
|
129
|
+
JWT_SECRET=your-very-secure-jwt-secret-here
|
|
130
|
+
JWT_EXPIRES_IN=24h
|
|
131
|
+
JWT_REFRESH_EXPIRES_IN=7d
|
|
132
|
+
|
|
133
|
+
# SMTP Configuration (Production)
|
|
134
|
+
SMTP_HOST=email-smtp.us-east-1.amazonaws.com
|
|
135
|
+
SMTP_PORT=587
|
|
136
|
+
SMTP_USER=your_smtp_username
|
|
137
|
+
SMTP_PASS=your_smtp_password
|
|
138
|
+
SMTP_FROM=noreply@yourdomain.com
|
|
139
|
+
|
|
140
|
+
# Cloud Storage (Optional)
|
|
141
|
+
S3_ACCESS_KEY_ID=your_aws_access_key
|
|
142
|
+
S3_SECRET_ACCESS_KEY=your_aws_secret_key
|
|
143
|
+
S3_BUCKET_NAME=your_bucket_name
|
|
144
|
+
S3_REGION=us-east-1
|
|
99
145
|
```
|
|
100
146
|
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
# Using npx
|
|
104
|
-
npx @fecommunity/reactpress-server start [options]
|
|
147
|
+
## API Documentation
|
|
105
148
|
|
|
106
|
-
|
|
107
|
-
|
|
149
|
+
Once running, visit `http://localhost:3002/api` for:
|
|
150
|
+
- Interactive Swagger documentation
|
|
151
|
+
- API endpoint explorer
|
|
152
|
+
- Authentication examples
|
|
153
|
+
- Response schemas
|
|
154
|
+
- Request/response validation
|
|
155
|
+
- Code generation for multiple languages
|
|
108
156
|
|
|
109
|
-
|
|
110
|
-
-p, --port <port> Server port (default: 3002)
|
|
111
|
-
```
|
|
157
|
+
## Development
|
|
112
158
|
|
|
113
|
-
### Build Project
|
|
114
159
|
```bash
|
|
115
|
-
#
|
|
116
|
-
|
|
160
|
+
# Clone repository
|
|
161
|
+
git clone https://github.com/fecommunity/reactpress.git
|
|
162
|
+
cd reactpress/server
|
|
117
163
|
|
|
118
|
-
#
|
|
119
|
-
|
|
120
|
-
```
|
|
164
|
+
# Install dependencies
|
|
165
|
+
pnpm install
|
|
121
166
|
|
|
122
|
-
|
|
167
|
+
# Start development server with hot reload
|
|
168
|
+
pnpm run dev
|
|
123
169
|
|
|
124
|
-
|
|
170
|
+
# Start with PM2 (development)
|
|
171
|
+
pnpm run pm2:start
|
|
125
172
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
SERVER_PORT=3002
|
|
129
|
-
SERVER_API_PREFIX=/api
|
|
130
|
-
NODE_ENV=development
|
|
173
|
+
# Build for production
|
|
174
|
+
pnpm run build
|
|
131
175
|
|
|
132
|
-
#
|
|
133
|
-
|
|
134
|
-
DB_PORT=3306
|
|
135
|
-
DB_USERNAME=root
|
|
136
|
-
DB_PASSWORD=your_password
|
|
137
|
-
DB_DATABASE=reactpress
|
|
138
|
-
|
|
139
|
-
# JWT Configuration
|
|
140
|
-
JWT_SECRET=your_jwt_secret_key
|
|
141
|
-
JWT_EXPIRES_IN=7d
|
|
142
|
-
|
|
143
|
-
# File Upload (Optional - Ali OSS)
|
|
144
|
-
OSS_ACCESS_KEY_ID=your_access_key_id
|
|
145
|
-
OSS_ACCESS_KEY_SECRET=your_access_key_secret
|
|
146
|
-
OSS_BUCKET=your_bucket_name
|
|
147
|
-
OSS_REGION=your_region
|
|
148
|
-
|
|
149
|
-
# Email Configuration (Optional)
|
|
150
|
-
EMAIL_HOST=smtp.gmail.com
|
|
151
|
-
EMAIL_PORT=587
|
|
152
|
-
EMAIL_USER=your_email@gmail.com
|
|
153
|
-
EMAIL_PASS=your_app_password
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Programmatic Usage
|
|
176
|
+
# Run tests
|
|
177
|
+
pnpm run test
|
|
157
178
|
|
|
158
|
-
|
|
179
|
+
# Run tests with coverage
|
|
180
|
+
pnpm run test:cov
|
|
159
181
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
async function startServer() {
|
|
164
|
-
const app = await bootstrap({
|
|
165
|
-
port: 3002,
|
|
166
|
-
apiPrefix: '/api',
|
|
167
|
-
cors: true
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
console.log('ReactPress server started successfully!');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
startServer();
|
|
182
|
+
# Run end-to-end tests
|
|
183
|
+
pnpm run test:e2e
|
|
174
184
|
```
|
|
175
185
|
|
|
176
|
-
##
|
|
177
|
-
|
|
178
|
-
The server provides comprehensive REST APIs:
|
|
179
|
-
|
|
180
|
-
### Authentication
|
|
181
|
-
- `POST /api/auth/login` - User login
|
|
182
|
-
- `POST /api/auth/register` - User registration
|
|
183
|
-
- `GET /api/auth/profile` - Get user profile
|
|
184
|
-
|
|
185
|
-
### Articles
|
|
186
|
-
- `GET /api/articles` - Get articles (with pagination)
|
|
187
|
-
- `POST /api/articles` - Create article
|
|
188
|
-
- `GET /api/articles/:id` - Get article by ID
|
|
189
|
-
- `PUT /api/articles/:id` - Update article
|
|
190
|
-
- `DELETE /api/articles/:id` - Delete article
|
|
191
|
-
|
|
192
|
-
### Categories
|
|
193
|
-
- `GET /api/categories` - Get all categories
|
|
194
|
-
- `POST /api/categories` - Create category
|
|
195
|
-
- `PUT /api/categories/:id` - Update category
|
|
196
|
-
- `DELETE /api/categories/:id` - Delete category
|
|
186
|
+
## Project Structure
|
|
197
187
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
188
|
+
```
|
|
189
|
+
server/
|
|
190
|
+
├── src/
|
|
191
|
+
│ ├── modules/ # Feature modules
|
|
192
|
+
│ │ ├── article/ # Article management
|
|
193
|
+
│ │ ├── auth/ # Authentication
|
|
194
|
+
│ │ ├── user/ # User management
|
|
195
|
+
│ │ └── ... # Other modules
|
|
196
|
+
│ ├── common/ # Shared utilities and decorators
|
|
197
|
+
│ ├── filters/ # Exception filters
|
|
198
|
+
│ ├── interceptors/ # Request/response interceptors
|
|
199
|
+
│ ├── guards/ # Authentication guards
|
|
200
|
+
│ ├── pipes/ # Data transformation pipes
|
|
201
|
+
│ ├── logger/ # Logging utilities
|
|
202
|
+
│ └── utils/ # Utility functions
|
|
203
|
+
├── public/ # Static assets
|
|
204
|
+
│ └── swagger/ # Swagger documentation
|
|
205
|
+
├── dist/ # Compiled output
|
|
206
|
+
└── bin/ # CLI entry points
|
|
207
|
+
```
|
|
203
208
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
## Environment Variables
|
|
210
|
+
|
|
211
|
+
| Variable | Description | Default |
|
|
212
|
+
|----------|-------------|---------|
|
|
213
|
+
| `DB_HOST` | Database host | `127.0.0.1` |
|
|
214
|
+
| `DB_PORT` | Database port | `3306` |
|
|
215
|
+
| `DB_USER` | Database username | - |
|
|
216
|
+
| `DB_PASSWD` | Database password | - |
|
|
217
|
+
| `DB_DATABASE` | Database name | `reactpress` |
|
|
218
|
+
| `SERVER_PORT` | Server port | `3002` |
|
|
219
|
+
| `JWT_SECRET` | JWT secret key | - |
|
|
220
|
+
| `CLIENT_SITE_URL` | Client site URL | `http://localhost:3001` |
|
|
221
|
+
| `SERVER_SITE_URL` | Server site URL | `http://localhost:3002` |
|
|
222
|
+
| `SMTP_HOST` | SMTP server host | - |
|
|
223
|
+
| `SMTP_PORT` | SMTP server port | - |
|
|
224
|
+
| `SMTP_USER` | SMTP username | - |
|
|
225
|
+
| `SMTP_PASS` | SMTP password | - |
|
|
209
226
|
|
|
210
|
-
|
|
211
|
-
- `POST /api/upload/image` - Upload image
|
|
212
|
-
- `POST /api/upload/file` - Upload file
|
|
227
|
+
## CLI Commands
|
|
213
228
|
|
|
214
|
-
|
|
229
|
+
```bash
|
|
230
|
+
# Show help
|
|
231
|
+
npx @fecommunity/reactpress-server --help
|
|
215
232
|
|
|
216
|
-
|
|
233
|
+
# Start server
|
|
234
|
+
npx @fecommunity/reactpress-server
|
|
217
235
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
sudo apt update
|
|
221
|
-
sudo apt install mysql-server
|
|
222
|
-
sudo mysql_secure_installation
|
|
223
|
-
```
|
|
236
|
+
# Start with PM2
|
|
237
|
+
npx @fecommunity/reactpress-server --pm2
|
|
224
238
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
brew install mysql
|
|
228
|
-
brew services start mysql
|
|
229
|
-
```
|
|
239
|
+
# Specify port
|
|
240
|
+
npx @fecommunity/reactpress-server --port 3002
|
|
230
241
|
|
|
231
|
-
|
|
232
|
-
|
|
242
|
+
# Enable verbose logging
|
|
243
|
+
npx @fecommunity/reactpress-server --verbose
|
|
233
244
|
|
|
234
|
-
|
|
245
|
+
# Run database migrations
|
|
246
|
+
npx @fecommunity/reactpress-server --migrate
|
|
235
247
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
CREATE USER 'reactpress'@'localhost' IDENTIFIED BY 'your_password';
|
|
239
|
-
GRANT ALL PRIVILEGES ON reactpress.* TO 'reactpress'@'localhost';
|
|
240
|
-
FLUSH PRIVILEGES;
|
|
248
|
+
# Seed database with sample data
|
|
249
|
+
npx @fecommunity/reactpress-server --seed
|
|
241
250
|
```
|
|
242
251
|
|
|
243
|
-
##
|
|
252
|
+
## Integration with ReactPress Toolkit
|
|
244
253
|
|
|
245
|
-
|
|
254
|
+
The server automatically generates the OpenAPI specification that powers the ReactPress Toolkit:
|
|
246
255
|
|
|
247
256
|
```typescript
|
|
248
|
-
|
|
249
|
-
import {
|
|
250
|
-
|
|
251
|
-
async function bootstrap() {
|
|
252
|
-
const app = await NestFactory.create(AppModule);
|
|
253
|
-
|
|
254
|
-
// Custom middleware
|
|
255
|
-
app.use('/custom', customMiddleware);
|
|
256
|
-
|
|
257
|
-
// Custom global filters
|
|
258
|
-
app.useGlobalFilters(new CustomExceptionFilter());
|
|
259
|
-
|
|
260
|
-
await app.listen(3002);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
bootstrap();
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Plugin Development
|
|
257
|
+
// The toolkit is automatically generated from this server's API
|
|
258
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
267
259
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
import { PluginInterface } from '@fecommunity/reactpress-server';
|
|
271
|
-
|
|
272
|
-
@Module({
|
|
273
|
-
// Your plugin implementation
|
|
274
|
-
})
|
|
275
|
-
export class CustomPlugin implements PluginInterface {
|
|
276
|
-
install() {
|
|
277
|
-
// Plugin installation logic
|
|
278
|
-
}
|
|
279
|
-
}
|
|
260
|
+
// All API endpoints are strongly typed
|
|
261
|
+
const articles: types.IArticle[] = await api.article.findAll();
|
|
280
262
|
```
|
|
281
263
|
|
|
282
|
-
##
|
|
283
|
-
|
|
284
|
-
|
|
264
|
+
## Database Schema
|
|
265
|
+
|
|
266
|
+
ReactPress uses MySQL/PostgreSQL with the following key tables:
|
|
267
|
+
- `users` - User accounts and profiles with 2FA support
|
|
268
|
+
- `articles` - Blog posts and content with versioning
|
|
269
|
+
- `categories` - Content categorization with hierarchy
|
|
270
|
+
- `tags` - Content tagging system
|
|
271
|
+
- `comments` - Reader comments and discussions with moderation
|
|
272
|
+
- `files` - Media file management with cloud storage
|
|
273
|
+
- `settings` - System configuration with environment overrides
|
|
274
|
+
- `views` - Analytics and tracking
|
|
275
|
+
- `webhooks` - Event-driven integrations
|
|
276
|
+
- `scheduled_tasks` - Automated operations
|
|
277
|
+
|
|
278
|
+
## Security Features
|
|
279
|
+
|
|
280
|
+
- **JWT Authentication** - Secure token-based authentication with refresh rotation
|
|
281
|
+
- **Rate Limiting** - Adaptive throttling to prevent abuse
|
|
282
|
+
- **Input Validation** - Sanitize all user inputs with Zod schema validation
|
|
283
|
+
- **Helmet.js** - Secure HTTP headers
|
|
284
|
+
- **CSRF Protection** - Prevent cross-site request forgery
|
|
285
|
+
- **SQL Injection Prevention** - Through TypeORM parameterized queries
|
|
286
|
+
- **CORS Configuration** - Controlled cross-origin resource sharing
|
|
287
|
+
- **Data Encryption** - At-rest encryption for sensitive data
|
|
288
|
+
- **Audit Logging** - Comprehensive activity tracking
|
|
289
|
+
|
|
290
|
+
## Performance Optimization
|
|
291
|
+
|
|
292
|
+
- **Database Indexing** - Optimized queries with proper indexing
|
|
293
|
+
- **Connection Pooling** - Efficient database connection management
|
|
294
|
+
- **Caching** - Redis integration for frequently accessed data
|
|
295
|
+
- **Compression** - Gzip compression for API responses
|
|
296
|
+
- **Pagination** - Efficient data retrieval for large datasets
|
|
297
|
+
- **Query Optimization** - TypeORM query builder for complex operations
|
|
298
|
+
- **Background Jobs** - Queue system for long-running tasks
|
|
299
|
+
|
|
300
|
+
## Testing
|
|
285
301
|
|
|
286
302
|
```bash
|
|
287
|
-
#
|
|
288
|
-
|
|
303
|
+
# Run unit tests
|
|
304
|
+
pnpm run test
|
|
289
305
|
|
|
290
|
-
#
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
# Monitor
|
|
294
|
-
pm2 monitor
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Docker
|
|
298
|
-
|
|
299
|
-
```dockerfile
|
|
300
|
-
FROM node:18-alpine
|
|
301
|
-
WORKDIR /app
|
|
302
|
-
COPY package*.json ./
|
|
303
|
-
RUN npm install
|
|
304
|
-
COPY . .
|
|
305
|
-
RUN npm run build
|
|
306
|
-
EXPOSE 3002
|
|
307
|
-
CMD ["npm", "start"]
|
|
308
|
-
```
|
|
306
|
+
# Run integration tests
|
|
307
|
+
pnpm run test:integration
|
|
309
308
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
```yaml
|
|
313
|
-
version: '3.8'
|
|
314
|
-
services:
|
|
315
|
-
reactpress-server:
|
|
316
|
-
build: .
|
|
317
|
-
ports:
|
|
318
|
-
- "3002:3002"
|
|
319
|
-
environment:
|
|
320
|
-
- DB_HOST=mysql
|
|
321
|
-
- DB_USERNAME=root
|
|
322
|
-
- DB_PASSWORD=password
|
|
323
|
-
- DB_DATABASE=reactpress
|
|
324
|
-
depends_on:
|
|
325
|
-
- mysql
|
|
326
|
-
|
|
327
|
-
mysql:
|
|
328
|
-
image: mysql:5.7
|
|
329
|
-
environment:
|
|
330
|
-
- MYSQL_ROOT_PASSWORD=password
|
|
331
|
-
- MYSQL_DATABASE=reactpress
|
|
332
|
-
ports:
|
|
333
|
-
- "3306:3306"
|
|
334
|
-
```
|
|
309
|
+
# Run end-to-end tests
|
|
310
|
+
pnpm run test:e2e
|
|
335
311
|
|
|
336
|
-
|
|
312
|
+
# Run tests with coverage
|
|
313
|
+
pnpm run test:cov
|
|
337
314
|
|
|
338
|
-
|
|
315
|
+
# Run linting
|
|
316
|
+
pnpm run lint
|
|
339
317
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
npm install @fecommunity/reactpress-server @fecommunity/reactpress-client @fecommunity/reactpress-config
|
|
318
|
+
# Run formatting
|
|
319
|
+
pnpm run format
|
|
343
320
|
|
|
344
|
-
#
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
# In another terminal, start client
|
|
348
|
-
npx reactpress-client dev
|
|
321
|
+
# Run type checking
|
|
322
|
+
pnpm run type-check
|
|
349
323
|
```
|
|
350
324
|
|
|
351
|
-
##
|
|
325
|
+
## Deployment
|
|
352
326
|
|
|
353
|
-
###
|
|
327
|
+
### Production Deployment with PM2
|
|
354
328
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
- Ensure MySQL is running
|
|
360
|
-
- Check database credentials in `.env`
|
|
329
|
+
```
|
|
330
|
+
# Start server with PM2
|
|
331
|
+
npx @fecommunity/reactpress-server --pm2
|
|
361
332
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
- Change port in `.env` file or use `-p` option
|
|
333
|
+
# Or build and start manually
|
|
334
|
+
pnpm run build
|
|
335
|
+
pnpm run start:prod
|
|
336
|
+
```
|
|
367
337
|
|
|
368
|
-
|
|
369
|
-
```
|
|
370
|
-
Error: JWT_SECRET is not defined
|
|
371
|
-
```
|
|
372
|
-
- Add `JWT_SECRET=your_secret_key` to `.env`
|
|
338
|
+
## Monitoring & Logging
|
|
373
339
|
|
|
374
|
-
|
|
340
|
+
- **Structured Logging** - JSON-formatted logs for easy parsing
|
|
341
|
+
- **Error Tracking** - Comprehensive error reporting with context
|
|
342
|
+
- **Performance Metrics** - Response time and throughput monitoring
|
|
343
|
+
- **Health Checks** - API endpoint for service status
|
|
344
|
+
- **Alerting** - Integration with monitoring systems (Prometheus, Grafana)
|
|
375
345
|
|
|
376
|
-
|
|
346
|
+
## Support
|
|
377
347
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
348
|
+
- 📖 [Documentation](https://github.com/fecommunity/reactpress)
|
|
349
|
+
- 🐛 [Issues](https://github.com/fecommunity/reactpress/issues)
|
|
350
|
+
- 💬 [Discussions](https://github.com/fecommunity/reactpress/discussions)
|
|
351
|
+
- 📧 [Enterprise Support](mailto:enterprise@reactpress.dev)
|
|
381
352
|
|
|
382
353
|
## Contributing
|
|
383
354
|
|
|
384
|
-
|
|
355
|
+
1. Fork the repository
|
|
356
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
357
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
358
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
359
|
+
5. Open a pull request
|
|
385
360
|
|
|
386
361
|
## License
|
|
387
362
|
|
|
388
|
-
MIT
|
|
363
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
389
364
|
|
|
390
|
-
|
|
365
|
+
---
|
|
391
366
|
|
|
392
|
-
|
|
393
|
-
- [Documentation](https://reactpress.surge.sh)
|
|
394
|
-
- [npm Package](https://www.npmjs.com/package/@fecommunity/reactpress-server)
|
|
395
|
-
- [API Documentation](http://localhost:3002/api) (when server is running)
|
|
367
|
+
Built with ❤️ by [FECommunity](https://github.com/fecommunity)
|