@fecommunity/reactpress-server 4.0.0-beta.3 → 4.0.0-beta.4
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/README.md +44 -318
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,366 +1,92 @@
|
|
|
1
1
|
# @fecommunity/reactpress-server
|
|
2
2
|
|
|
3
|
-
ReactPress
|
|
3
|
+
NestJS CMS API for **ReactPress 4.0** — articles, pages, media, users, plugins, themes, and site settings. Headless REST with Swagger; powers themes, Admin, and desktop via [@fecommunity/reactpress-toolkit](../toolkit/).
|
|
4
|
+
|
|
5
|
+
> **MySQL** for production · **SQLite** for desktop / local mode.
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/@fecommunity/reactpress-server)
|
|
6
8
|
[](https://github.com/fecommunity/reactpress/blob/master/server/LICENSE)
|
|
7
|
-
[](https://nodejs.org)
|
|
8
|
-
[](http://www.typescriptlang.org/)
|
|
9
9
|
[](https://nestjs.com/)
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
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.
|
|
14
|
-
|
|
15
|
-
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](../toolkit).
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
### Installation & Setup
|
|
11
|
+
## Quick start
|
|
20
12
|
|
|
21
13
|
```bash
|
|
22
|
-
# Regular startup
|
|
23
14
|
npx @fecommunity/reactpress-server
|
|
24
|
-
|
|
25
|
-
# PM2 startup for production
|
|
15
|
+
# production with PM2
|
|
26
16
|
npx @fecommunity/reactpress-server --pm2
|
|
27
17
|
```
|
|
28
18
|
|
|
29
|
-
|
|
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`
|
|
19
|
+
On first run, the install wizard opens in your browser, creates configuration, and starts the API at `http://localhost:3002` (Swagger: `/api`).
|
|
35
20
|
|
|
36
21
|
## Features
|
|
37
22
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
- ⚡ **PM2 Support** - Optional PM2 process management
|
|
44
|
-
- 🔐 **Security** - JWT with refresh token rotation, rate limiting
|
|
45
|
-
- 🛡️ **Protection** - Helmet.js, CSRF protection, input validation
|
|
46
|
-
- 📱 **Responsive APIs** - Mobile-friendly RESTful endpoints
|
|
47
|
-
- 🌐 **Globalization** - Multi-language support
|
|
48
|
-
- 📊 **Analytics Tracking** - Built-in view and visitor analytics
|
|
49
|
-
- 🔄 **Data Synchronization** - Scheduled tasks and webhook support
|
|
23
|
+
- REST API for content, media, comments, search, and site settings
|
|
24
|
+
- Plugin hook runtime and theme catalog integration (ReactPress 4.0)
|
|
25
|
+
- JWT auth, rate limiting, validation, and Swagger documentation
|
|
26
|
+
- MySQL (default) or SQLite (desktop / local mode)
|
|
27
|
+
- PM2 support for production
|
|
50
28
|
|
|
51
29
|
## Requirements
|
|
52
30
|
|
|
53
|
-
- Node.js >=
|
|
54
|
-
- MySQL 8.0+ or
|
|
55
|
-
- npm or pnpm
|
|
56
|
-
|
|
57
|
-
## Usage Scenarios
|
|
58
|
-
|
|
59
|
-
### Standalone API Server
|
|
60
|
-
Perfect for:
|
|
61
|
-
- Headless CMS implementation
|
|
62
|
-
- Mobile app backend
|
|
63
|
-
- Microservices architecture
|
|
64
|
-
- Custom frontend integration
|
|
65
|
-
- Enterprise API gateway
|
|
66
|
-
|
|
67
|
-
### Full ReactPress Stack
|
|
68
|
-
Use with ReactPress client for complete CMS solution:
|
|
69
|
-
```bash
|
|
70
|
-
# Start server
|
|
71
|
-
npx @fecommunity/reactpress-server
|
|
72
|
-
|
|
73
|
-
# In another terminal, start client
|
|
74
|
-
npx @fecommunity/reactpress-client
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## API Modules
|
|
78
|
-
|
|
79
|
-
ReactPress Server provides comprehensive API modules:
|
|
80
|
-
|
|
81
|
-
- **Article Management** - Create, read, update, delete articles with versioning
|
|
82
|
-
- **User Authentication** - Registration, login, password management, 2FA
|
|
83
|
-
- **Comment System** - Comment moderation and management with spam detection
|
|
84
|
-
- **Media Management** - File upload and management (local/S3/Cloudinary)
|
|
85
|
-
- **Category & Tag** - Content organization systems with hierarchy
|
|
86
|
-
- **Page Management** - Custom page creation with templates
|
|
87
|
-
- **Settings** - System configuration management with environment overrides
|
|
88
|
-
- **SMTP** - Email sending capabilities with template system
|
|
89
|
-
- **Search** - Full-text search functionality with Elasticsearch integration
|
|
90
|
-
- **Analytics** - Visitor and view tracking with export capabilities
|
|
91
|
-
- **Webhooks** - Event-driven integrations with external services
|
|
92
|
-
- **Scheduled Tasks** - Cron jobs for automated operations
|
|
93
|
-
|
|
94
|
-
## PM2 Support
|
|
95
|
-
|
|
96
|
-
ReactPress server supports PM2 process management for production deployments:
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Start with PM2
|
|
100
|
-
npx @fecommunity/reactpress-server --pm2
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
PM2 features:
|
|
104
|
-
- Automatic process restart on crash
|
|
105
|
-
- Memory monitoring
|
|
106
|
-
- Log management with rotation
|
|
107
|
-
- Process management
|
|
108
|
-
- Health checks
|
|
109
|
-
|
|
110
|
-
## Configuration
|
|
111
|
-
|
|
112
|
-
The installation wizard will create a `.env` file with:
|
|
113
|
-
|
|
114
|
-
```env
|
|
115
|
-
# Database Configuration (Production)
|
|
116
|
-
DB_HOST=prod-db.cluster-xyz.amazonaws.com
|
|
117
|
-
DB_PORT=3306
|
|
118
|
-
DB_USER=reactpress_user
|
|
119
|
-
DB_PASSWD=secure_password_here
|
|
120
|
-
DB_DATABASE=reactpress_prod
|
|
121
|
-
DB_SSL=true
|
|
122
|
-
|
|
123
|
-
# Site URLs (Production)
|
|
124
|
-
CLIENT_SITE_URL=https://yourdomain.com
|
|
125
|
-
SERVER_SITE_URL=https://api.yourdomain.com
|
|
126
|
-
|
|
127
|
-
# Security Settings (Production)
|
|
128
|
-
JWT_SECRET=your-very-secure-jwt-secret-here
|
|
129
|
-
JWT_EXPIRES_IN=24h
|
|
130
|
-
JWT_REFRESH_EXPIRES_IN=7d
|
|
131
|
-
|
|
132
|
-
# SMTP Configuration (Production)
|
|
133
|
-
SMTP_HOST=email-smtp.us-east-1.amazonaws.com
|
|
134
|
-
SMTP_PORT=587
|
|
135
|
-
SMTP_USER=your_smtp_username
|
|
136
|
-
SMTP_PASS=your_smtp_password
|
|
137
|
-
SMTP_FROM=noreply@yourdomain.com
|
|
138
|
-
|
|
139
|
-
# Cloud Storage (Optional)
|
|
140
|
-
S3_ACCESS_KEY_ID=your_aws_access_key
|
|
141
|
-
S3_SECRET_ACCESS_KEY=your_aws_secret_key
|
|
142
|
-
S3_BUCKET_NAME=your_bucket_name
|
|
143
|
-
S3_REGION=us-east-1
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## API Documentation
|
|
147
|
-
|
|
148
|
-
Once running, visit `http://localhost:3002/api` for:
|
|
149
|
-
- Interactive Swagger documentation
|
|
150
|
-
- API endpoint explorer
|
|
151
|
-
- Authentication examples
|
|
152
|
-
- Response schemas
|
|
153
|
-
- Request/response validation
|
|
154
|
-
- Code generation for multiple languages
|
|
31
|
+
- Node.js >= 20
|
|
32
|
+
- MySQL 8.0+ (production) or SQLite (local/desktop)
|
|
33
|
+
- npm or pnpm
|
|
155
34
|
|
|
156
35
|
## Development
|
|
157
36
|
|
|
158
37
|
```bash
|
|
159
|
-
# Clone repository
|
|
160
38
|
git clone https://github.com/fecommunity/reactpress.git
|
|
161
|
-
cd reactpress
|
|
162
|
-
|
|
163
|
-
# Install dependencies
|
|
39
|
+
cd reactpress
|
|
164
40
|
pnpm install
|
|
165
|
-
|
|
166
|
-
# Start development server with hot reload
|
|
167
|
-
pnpm run dev
|
|
168
|
-
|
|
169
|
-
# Start with PM2 (development)
|
|
170
|
-
pnpm run pm2:start
|
|
171
|
-
|
|
172
|
-
# Build for production
|
|
173
|
-
pnpm run build
|
|
174
|
-
|
|
175
|
-
# Run tests
|
|
176
|
-
pnpm run test
|
|
177
|
-
|
|
178
|
-
# Run tests with coverage
|
|
179
|
-
pnpm run test:cov
|
|
180
|
-
|
|
181
|
-
# Run end-to-end tests
|
|
182
|
-
pnpm run test:e2e
|
|
41
|
+
pnpm run --dir server dev
|
|
183
42
|
```
|
|
184
43
|
|
|
185
|
-
|
|
44
|
+
| Command | Description |
|
|
45
|
+
| :--- | :--- |
|
|
46
|
+
| `pnpm run dev` | Dev server with hot reload |
|
|
47
|
+
| `pnpm run build` | Production build |
|
|
48
|
+
| `pnpm run test` | Unit tests |
|
|
49
|
+
| `pnpm run pm2:start` | Start with PM2 |
|
|
50
|
+
|
|
51
|
+
## Project structure
|
|
186
52
|
|
|
187
53
|
```
|
|
188
54
|
server/
|
|
189
|
-
├── src/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
│ │ ├── user/ # User management
|
|
194
|
-
│ │ └── ... # Other modules
|
|
195
|
-
│ ├── common/ # Shared utilities and decorators
|
|
196
|
-
│ ├── filters/ # Exception filters
|
|
197
|
-
│ ├── interceptors/ # Request/response interceptors
|
|
198
|
-
│ ├── guards/ # Authentication guards
|
|
199
|
-
│ ├── pipes/ # Data transformation pipes
|
|
200
|
-
│ ├── logger/ # Logging utilities
|
|
201
|
-
│ └── utils/ # Utility functions
|
|
202
|
-
├── public/ # Static assets
|
|
203
|
-
│ └── swagger/ # Swagger documentation
|
|
204
|
-
├── dist/ # Compiled output
|
|
205
|
-
└── bin/ # CLI entry points
|
|
55
|
+
├── src/modules/ # Feature modules (article, auth, plugin, theme, …)
|
|
56
|
+
├── src/common/ # Shared utilities
|
|
57
|
+
├── public/ # Static assets and Swagger UI
|
|
58
|
+
└── bin/ # CLI entry points
|
|
206
59
|
```
|
|
207
60
|
|
|
208
|
-
##
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
The install wizard generates `.env`. Key variables:
|
|
209
64
|
|
|
210
65
|
| Variable | Description | Default |
|
|
211
|
-
|
|
66
|
+
| :--- | :--- | :--- |
|
|
212
67
|
| `DB_HOST` | Database host | `127.0.0.1` |
|
|
213
68
|
| `DB_PORT` | Database port | `3306` |
|
|
214
|
-
| `DB_USER` | Database username | - |
|
|
215
|
-
| `DB_PASSWD` | Database password | - |
|
|
216
69
|
| `DB_DATABASE` | Database name | `reactpress` |
|
|
217
|
-
| `SERVER_PORT` |
|
|
218
|
-
| `JWT_SECRET` | JWT
|
|
219
|
-
| `CLIENT_SITE_URL` |
|
|
220
|
-
| `SERVER_SITE_URL` | Server site URL | `http://localhost:3002` |
|
|
221
|
-
| `SMTP_HOST` | SMTP server host | - |
|
|
222
|
-
| `SMTP_PORT` | SMTP server port | - |
|
|
223
|
-
| `SMTP_USER` | SMTP username | - |
|
|
224
|
-
| `SMTP_PASS` | SMTP password | - |
|
|
225
|
-
|
|
226
|
-
## CLI Commands
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# Show help
|
|
230
|
-
npx @fecommunity/reactpress-server --help
|
|
231
|
-
|
|
232
|
-
# Start server
|
|
233
|
-
npx @fecommunity/reactpress-server
|
|
234
|
-
|
|
235
|
-
# Start with PM2
|
|
236
|
-
npx @fecommunity/reactpress-server --pm2
|
|
237
|
-
|
|
238
|
-
# Specify port
|
|
239
|
-
npx @fecommunity/reactpress-server --port 3002
|
|
240
|
-
|
|
241
|
-
# Enable verbose logging
|
|
242
|
-
npx @fecommunity/reactpress-server --verbose
|
|
70
|
+
| `SERVER_PORT` | API port | `3002` |
|
|
71
|
+
| `JWT_SECRET` | JWT signing key | — |
|
|
72
|
+
| `CLIENT_SITE_URL` | Public site URL | `http://localhost:3001` |
|
|
243
73
|
|
|
244
|
-
|
|
245
|
-
npx @fecommunity/reactpress-server --migrate
|
|
246
|
-
|
|
247
|
-
# Seed database with sample data
|
|
248
|
-
npx @fecommunity/reactpress-server --seed
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
## Integration with ReactPress Toolkit
|
|
252
|
-
|
|
253
|
-
The server automatically generates the OpenAPI specification that powers the ReactPress Toolkit:
|
|
74
|
+
## Integration
|
|
254
75
|
|
|
255
76
|
```typescript
|
|
256
|
-
|
|
257
|
-
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
77
|
+
import { api } from '@fecommunity/reactpress-toolkit';
|
|
258
78
|
|
|
259
|
-
|
|
260
|
-
const articles: types.IArticle[] = await api.article.findAll();
|
|
79
|
+
const articles = await api.article.findAll();
|
|
261
80
|
```
|
|
262
81
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
ReactPress uses MySQL/PostgreSQL with the following key tables:
|
|
266
|
-
- `users` - User accounts and profiles with 2FA support
|
|
267
|
-
- `articles` - Blog posts and content with versioning
|
|
268
|
-
- `categories` - Content categorization with hierarchy
|
|
269
|
-
- `tags` - Content tagging system
|
|
270
|
-
- `comments` - Reader comments and discussions with moderation
|
|
271
|
-
- `files` - Media file management
|
|
272
|
-
- `settings` - System configuration with environment overrides
|
|
273
|
-
- `views` - Analytics and tracking
|
|
274
|
-
- `webhooks` - Event-driven integrations
|
|
275
|
-
- `scheduled_tasks` - Automated operations
|
|
276
|
-
|
|
277
|
-
## Security Features
|
|
82
|
+
OpenAPI spec from this server drives toolkit code generation (`pnpm run --dir toolkit generate`).
|
|
278
83
|
|
|
279
|
-
|
|
280
|
-
- **Rate Limiting** - Adaptive throttling to prevent abuse
|
|
281
|
-
- **Input Validation** - Sanitize all user inputs with Zod schema validation
|
|
282
|
-
- **Helmet.js** - Secure HTTP headers
|
|
283
|
-
- **CSRF Protection** - Prevent cross-site request forgery
|
|
284
|
-
- **SQL Injection Prevention** - Through TypeORM parameterized queries
|
|
285
|
-
- **CORS Configuration** - Controlled cross-origin resource sharing
|
|
286
|
-
- **Data Encryption** - At-rest encryption for sensitive data
|
|
287
|
-
- **Audit Logging** - Comprehensive activity tracking
|
|
288
|
-
|
|
289
|
-
## Performance Optimization
|
|
290
|
-
|
|
291
|
-
- **Database Indexing** - Optimized queries with proper indexing
|
|
292
|
-
- **Connection Pooling** - Efficient database connection management
|
|
293
|
-
- **Caching** - Redis integration for frequently accessed data
|
|
294
|
-
- **Compression** - Gzip compression for API responses
|
|
295
|
-
- **Pagination** - Efficient data retrieval for large datasets
|
|
296
|
-
- **Query Optimization** - TypeORM query builder for complex operations
|
|
297
|
-
- **Background Jobs** - Queue system for long-running tasks
|
|
298
|
-
|
|
299
|
-
## Testing
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
# Run unit tests
|
|
303
|
-
pnpm run test
|
|
84
|
+
## Docs & support
|
|
304
85
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
# Run end-to-end tests
|
|
309
|
-
pnpm run test:e2e
|
|
310
|
-
|
|
311
|
-
# Run tests with coverage
|
|
312
|
-
pnpm run test:cov
|
|
313
|
-
|
|
314
|
-
# Run linting
|
|
315
|
-
pnpm run lint
|
|
316
|
-
|
|
317
|
-
# Run formatting
|
|
318
|
-
pnpm run format
|
|
319
|
-
|
|
320
|
-
# Run type checking
|
|
321
|
-
pnpm run type-check
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
## Deployment
|
|
325
|
-
|
|
326
|
-
### Production Deployment with PM2
|
|
327
|
-
|
|
328
|
-
```
|
|
329
|
-
# Start server with PM2
|
|
330
|
-
npx @fecommunity/reactpress-server --pm2
|
|
331
|
-
|
|
332
|
-
# Or build and start manually
|
|
333
|
-
pnpm run build
|
|
334
|
-
pnpm run start:prod
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
## Monitoring & Logging
|
|
338
|
-
|
|
339
|
-
- **Structured Logging** - JSON-formatted logs for easy parsing
|
|
340
|
-
- **Error Tracking** - Comprehensive error reporting with context
|
|
341
|
-
- **Performance Metrics** - Response time and throughput monitoring
|
|
342
|
-
- **Health Checks** - API endpoint for service status
|
|
343
|
-
- **Alerting** - Basic alerting capabilities
|
|
344
|
-
|
|
345
|
-
## Support
|
|
346
|
-
|
|
347
|
-
- 📖 [Documentation](https://github.com/fecommunity/reactpress)
|
|
348
|
-
- 🐛 [Issues](https://github.com/fecommunity/reactpress/issues)
|
|
349
|
-
- 💬 [Discussions](https://github.com/fecommunity/reactpress/discussions)
|
|
350
|
-
- 📧 [Support](mailto:support@reactpress.dev)
|
|
351
|
-
|
|
352
|
-
## Contributing
|
|
353
|
-
|
|
354
|
-
1. Fork the repository
|
|
355
|
-
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
356
|
-
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
357
|
-
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
358
|
-
5. Open a pull request
|
|
86
|
+
- [Documentation](https://reactpress-docs.vercel.app/)
|
|
87
|
+
- [Issues](https://github.com/fecommunity/reactpress/issues)
|
|
88
|
+
- [Contributing](../CONTRIBUTING.md)
|
|
359
89
|
|
|
360
90
|
## License
|
|
361
91
|
|
|
362
|
-
MIT
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
Built with ❤️ by [FECommunity](https://github.com/fecommunity)
|
|
92
|
+
MIT — see [LICENSE](LICENSE).
|