@fecommunity/reactpress-server 1.0.5-beta.0 → 3.0.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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +278 -307
  3. package/bin/reactpress-server.js +175 -274
  4. package/dist/app.module.js +28 -3
  5. package/dist/app.module.js.map +1 -1
  6. package/dist/common/api-messages.d.ts +32 -0
  7. package/dist/common/api-messages.js +36 -0
  8. package/dist/common/api-messages.js.map +1 -0
  9. package/dist/generate-swagger.d.ts +1 -0
  10. package/dist/generate-swagger.js +73 -0
  11. package/dist/generate-swagger.js.map +1 -0
  12. package/dist/main.d.ts +5 -0
  13. package/dist/main.js +258 -39
  14. package/dist/main.js.map +1 -1
  15. package/dist/modules/api-key/api-key.controller.d.ts +14 -0
  16. package/dist/modules/api-key/api-key.controller.js +63 -0
  17. package/dist/modules/api-key/api-key.controller.js.map +1 -0
  18. package/dist/modules/api-key/api-key.entity.d.ts +11 -0
  19. package/dist/modules/api-key/api-key.entity.js +63 -0
  20. package/dist/modules/api-key/api-key.entity.js.map +1 -0
  21. package/dist/modules/api-key/api-key.guard.d.ts +7 -0
  22. package/dist/modules/api-key/api-key.guard.js +40 -0
  23. package/dist/modules/api-key/api-key.guard.js.map +1 -0
  24. package/dist/modules/api-key/api-key.module.d.ts +2 -0
  25. package/dist/modules/api-key/api-key.module.js +28 -0
  26. package/dist/modules/api-key/api-key.module.js.map +1 -0
  27. package/dist/modules/api-key/api-key.service.d.ts +15 -0
  28. package/dist/modules/api-key/api-key.service.js +81 -0
  29. package/dist/modules/api-key/api-key.service.js.map +1 -0
  30. package/dist/modules/article/article-revision.entity.d.ts +11 -0
  31. package/dist/modules/article/article-revision.entity.js +53 -0
  32. package/dist/modules/article/article-revision.entity.js.map +1 -0
  33. package/dist/modules/article/article.controller.d.ts +6 -1
  34. package/dist/modules/article/article.controller.js +45 -1
  35. package/dist/modules/article/article.controller.js.map +1 -1
  36. package/dist/modules/article/article.entity.d.ts +1 -0
  37. package/dist/modules/article/article.entity.js +5 -0
  38. package/dist/modules/article/article.entity.js.map +1 -1
  39. package/dist/modules/article/article.module.js +14 -2
  40. package/dist/modules/article/article.module.js.map +1 -1
  41. package/dist/modules/article/article.service.d.ts +9 -1
  42. package/dist/modules/article/article.service.js +59 -5
  43. package/dist/modules/article/article.service.js.map +1 -1
  44. package/dist/modules/article/scheduled-publish.service.d.ts +13 -0
  45. package/dist/modules/article/scheduled-publish.service.js +65 -0
  46. package/dist/modules/article/scheduled-publish.service.js.map +1 -0
  47. package/dist/modules/auth/auth.service.js +4 -3
  48. package/dist/modules/auth/auth.service.js.map +1 -1
  49. package/dist/modules/auth/jwt-auth.guard.js +2 -1
  50. package/dist/modules/auth/jwt-auth.guard.js.map +1 -1
  51. package/dist/modules/auth/jwt.strategy.js +2 -1
  52. package/dist/modules/auth/jwt.strategy.js.map +1 -1
  53. package/dist/modules/category/category.service.js +3 -2
  54. package/dist/modules/category/category.service.js.map +1 -1
  55. package/dist/modules/comment/comment.module.js +10 -1
  56. package/dist/modules/comment/comment.module.js.map +1 -1
  57. package/dist/modules/comment/comment.service.d.ts +3 -1
  58. package/dist/modules/comment/comment.service.js +15 -5
  59. package/dist/modules/comment/comment.service.js.map +1 -1
  60. package/dist/modules/health/health.controller.d.ts +11 -0
  61. package/dist/modules/health/health.controller.js +57 -0
  62. package/dist/modules/health/health.controller.js.map +1 -0
  63. package/dist/modules/health/health.module.d.ts +2 -0
  64. package/dist/modules/health/health.module.js +20 -0
  65. package/dist/modules/health/health.module.js.map +1 -0
  66. package/dist/modules/knowledge/knowledge.service.js +3 -2
  67. package/dist/modules/knowledge/knowledge.service.js.map +1 -1
  68. package/dist/modules/page/page.service.js +2 -1
  69. package/dist/modules/page/page.service.js.map +1 -1
  70. package/dist/modules/setting/setting.constant.d.ts +2 -3
  71. package/dist/modules/setting/setting.constant.js +4 -3
  72. package/dist/modules/setting/setting.constant.js.map +1 -1
  73. package/dist/modules/setting/setting.service.js +34 -11
  74. package/dist/modules/setting/setting.service.js.map +1 -1
  75. package/dist/modules/smtp/smtp.service.js +2 -1
  76. package/dist/modules/smtp/smtp.service.js.map +1 -1
  77. package/dist/modules/tag/tag.service.js +3 -2
  78. package/dist/modules/tag/tag.service.js.map +1 -1
  79. package/dist/modules/user/user.controller.js +4 -3
  80. package/dist/modules/user/user.controller.js.map +1 -1
  81. package/dist/modules/user/user.service.js +10 -9
  82. package/dist/modules/user/user.service.js.map +1 -1
  83. package/dist/modules/webhook/webhook.controller.d.ts +12 -0
  84. package/dist/modules/webhook/webhook.controller.js +63 -0
  85. package/dist/modules/webhook/webhook.controller.js.map +1 -0
  86. package/dist/modules/webhook/webhook.entity.d.ts +9 -0
  87. package/dist/modules/webhook/webhook.entity.js +54 -0
  88. package/dist/modules/webhook/webhook.entity.js.map +1 -0
  89. package/dist/modules/webhook/webhook.module.d.ts +2 -0
  90. package/dist/modules/webhook/webhook.module.js +27 -0
  91. package/dist/modules/webhook/webhook.module.js.map +1 -0
  92. package/dist/modules/webhook/webhook.service.d.ts +16 -0
  93. package/dist/modules/webhook/webhook.service.js +97 -0
  94. package/dist/modules/webhook/webhook.service.js.map +1 -0
  95. package/dist/public/favicon.png +0 -0
  96. package/dist/public/index.html +439 -0
  97. package/dist/public/swagger/custom.css +11 -0
  98. package/dist/starter.d.ts +1 -0
  99. package/dist/starter.js +84 -0
  100. package/dist/starter.js.map +1 -0
  101. package/dist/tsconfig.build.tsbuildinfo +4963 -3719
  102. package/dist/utils/oss.util.js +2 -1
  103. package/dist/utils/oss.util.js.map +1 -1
  104. package/package.json +41 -32
  105. package/public/favicon.png +0 -0
  106. package/public/index.html +439 -0
  107. package/public/swagger/custom.css +11 -0
  108. package/dist/bootstrap.d.ts +0 -10
  109. package/dist/bootstrap.js +0 -57
  110. package/dist/bootstrap.js.map +0 -1
package/README.md CHANGED
@@ -1,395 +1,366 @@
1
1
  # @fecommunity/reactpress-server
2
2
 
3
- NestJS-based backend API server for ReactPress - A modern React-based CMS platform.
3
+ ReactPress Server - NestJS 10 backend API for ReactPress CMS with simple installation.
4
4
 
5
- ## Installation
5
+ [![NPM Version](https://img.shields.io/npm/v/@fecommunity/reactpress-server.svg)](https://www.npmjs.com/package/@fecommunity/reactpress-server)
6
+ [![License](https://img.shields.io/npm/l/@fecommunity/reactpress-server.svg)](https://github.com/fecommunity/reactpress/blob/master/server/LICENSE)
7
+ [![Node Version](https://img.shields.io/node/v/@fecommunity/reactpress-server.svg)](https://nodejs.org)
8
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
9
+ [![NestJS](https://img.shields.io/badge/NestJS-10-red)](https://nestjs.com/)
6
10
 
7
- ```bash
8
- # For new projects
9
- npm install @fecommunity/reactpress-server @fecommunity/reactpress-config
10
-
11
- # Using yarn
12
- yarn add @fecommunity/reactpress-server @fecommunity/reactpress-config
13
-
14
- # Using pnpm in workspace root (add -w flag)
15
- pnpm add -w @fecommunity/reactpress-server @fecommunity/reactpress-config
16
-
17
- # Using pnpm in standalone project
18
- pnpm add @fecommunity/reactpress-server @fecommunity/reactpress-config
19
- ```
11
+ ## Overview
20
12
 
21
- ## Features
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.
22
14
 
23
- - 🚀 **NestJS Framework** - Built on modern, scalable Node.js framework
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 extensible and maintainable. It automatically generates OpenAPI/Swagger documentation that powers the [ReactPress Toolkit](../toolkit).
31
16
 
32
17
  ## Quick Start
33
18
 
34
- ### 1. Initialize Server
19
+ ### Installation & Setup
35
20
 
36
21
  ```bash
37
- # Using npx (recommended for first-time use)
38
- npx @fecommunity/reactpress-server init
22
+ # Regular startup
23
+ npx @fecommunity/reactpress-server
39
24
 
40
- # Or if installed globally
41
- reactpress-server init
25
+ # PM2 startup for production
26
+ npx @fecommunity/reactpress-server --pm2
42
27
  ```
43
28
 
44
- This will create configuration files and set up your environment.
45
-
46
- ### 2. Start Development Server
47
-
48
- ```bash
49
- # Using npx
50
- npx @fecommunity/reactpress-server dev
51
-
52
- # Or if installed globally
53
- reactpress-server dev
54
- ```
29
+ That's it! The command will automatically:
55
30
 
56
- The server will start on `http://localhost:3002` with API documentation at `http://localhost:3002/api`.
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`
57
35
 
58
- ### 3. Start Production Server
36
+ ## Features
59
37
 
38
+ - 🚀 **Simple Installation** - No complex CLI parameters needed
39
+ - 🔧 **Auto-Configuration** - Generates `.env` files automatically
40
+ - 🔌 **Database Setup** - Creates MySQL database with migrations
41
+ - 🎯 **Seamless Flow** - From installation to running server
42
+ - 📖 **Auto-Documentation** - Swagger API docs available immediately
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
50
+
51
+ ## Requirements
52
+
53
+ - Node.js >= 18.20.4
54
+ - MySQL 8.0+ or PostgreSQL 13+
55
+ - npm or pnpm package manager
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:
60
69
  ```bash
61
- # Using npx
62
- npx @fecommunity/reactpress-server start
70
+ # Start server
71
+ npx @fecommunity/reactpress-server
63
72
 
64
- # Or if installed globally
65
- reactpress-server start
73
+ # In another terminal, start client
74
+ npx @fecommunity/reactpress-client
66
75
  ```
67
76
 
68
- ## CLI Commands
77
+ ## API Modules
69
78
 
70
- The package includes a powerful CLI for server management:
79
+ ReactPress Server provides comprehensive API modules:
71
80
 
72
- ### Initialize Project
73
- ```bash
74
- # Using npx (recommended)
75
- npx @fecommunity/reactpress-server init [options]
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)
86
- ```
87
-
88
- ### Development Mode
89
- ```bash
90
- # Using npx
91
- npx @fecommunity/reactpress-server dev [options]
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
92
93
 
93
- # Or if installed globally
94
- reactpress-server dev [options]
94
+ ## PM2 Support
95
95
 
96
- Options:
97
- -p, --port <port> Server port (default: 3002)
98
- --no-open Don't open browser automatically
99
- ```
96
+ ReactPress server supports PM2 process management for production deployments:
100
97
 
101
- ### Production Mode
102
98
  ```bash
103
- # Using npx
104
- npx @fecommunity/reactpress-server start [options]
105
-
106
- # Or if installed globally
107
- reactpress-server start [options]
108
-
109
- Options:
110
- -p, --port <port> Server port (default: 3002)
99
+ # Start with PM2
100
+ npx @fecommunity/reactpress-server --pm2
111
101
  ```
112
102
 
113
- ### Build Project
114
- ```bash
115
- # Using npx
116
- npx @fecommunity/reactpress-server build
103
+ PM2 features:
104
+ - Automatic process restart on crash
105
+ - Memory monitoring
106
+ - Log management with rotation
107
+ - Process management
108
+ - Health checks
117
109
 
118
- # Or if installed globally
119
- reactpress-server build
120
- ```
121
-
122
- ## Environment Configuration
110
+ ## Configuration
123
111
 
124
- Create a `.env` file in your project root:
112
+ The installation wizard will create a `.env` file with:
125
113
 
126
114
  ```env
127
- # Server Configuration
128
- SERVER_PORT=3002
129
- SERVER_API_PREFIX=/api
130
- NODE_ENV=development
131
-
132
- # Database Configuration
133
- DB_HOST=localhost
115
+ # Database Configuration (Production)
116
+ DB_HOST=prod-db.cluster-xyz.amazonaws.com
134
117
  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
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
154
144
  ```
155
145
 
156
- ## Programmatic Usage
146
+ ## API Documentation
157
147
 
158
- You can also use the server programmatically in your Node.js applications:
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
159
155
 
160
- ```typescript
161
- import { bootstrap } from '@fecommunity/reactpress-server';
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();
174
- ```
175
-
176
- ## API Endpoints
156
+ ## Development
177
157
 
178
- The server provides comprehensive REST APIs:
158
+ ```bash
159
+ # Clone repository
160
+ git clone https://github.com/fecommunity/reactpress.git
161
+ cd reactpress/server
179
162
 
180
- ### Authentication
181
- - `POST /api/auth/login` - User login
182
- - `POST /api/auth/register` - User registration
183
- - `GET /api/auth/profile` - Get user profile
163
+ # Install dependencies
164
+ pnpm install
184
165
 
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
166
+ # Start development server with hot reload
167
+ pnpm run dev
191
168
 
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
169
+ # Start with PM2 (development)
170
+ pnpm run pm2:start
197
171
 
198
- ### Tags
199
- - `GET /api/tags` - Get all tags
200
- - `POST /api/tags` - Create tag
201
- - `PUT /api/tags/:id` - Update tag
202
- - `DELETE /api/tags/:id` - Delete tag
172
+ # Build for production
173
+ pnpm run build
203
174
 
204
- ### Comments
205
- - `GET /api/comments` - Get comments
206
- - `POST /api/comments` - Create comment
207
- - `PUT /api/comments/:id` - Update comment
208
- - `DELETE /api/comments/:id` - Delete comment
175
+ # Run tests
176
+ pnpm run test
209
177
 
210
- ### File Upload
211
- - `POST /api/upload/image` - Upload image
212
- - `POST /api/upload/file` - Upload file
178
+ # Run tests with coverage
179
+ pnpm run test:cov
213
180
 
214
- ## Database Setup
181
+ # Run end-to-end tests
182
+ pnpm run test:e2e
183
+ ```
215
184
 
216
- ### MySQL Installation
185
+ ## Project Structure
217
186
 
218
- **Ubuntu/Debian:**
219
- ```bash
220
- sudo apt update
221
- sudo apt install mysql-server
222
- sudo mysql_secure_installation
223
187
  ```
224
-
225
- **macOS:**
226
- ```bash
227
- brew install mysql
228
- brew services start mysql
188
+ server/
189
+ ├── src/
190
+ │ ├── modules/ # Feature modules
191
+ │ │ ├── article/ # Article management
192
+ │ │ ├── auth/ # Authentication
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
229
206
  ```
230
207
 
231
- **Windows:**
232
- Download and install from [MySQL Official Website](https://dev.mysql.com/downloads/mysql/)
208
+ ## Environment Variables
209
+
210
+ | Variable | Description | Default |
211
+ |----------|-------------|---------|
212
+ | `DB_HOST` | Database host | `127.0.0.1` |
213
+ | `DB_PORT` | Database port | `3306` |
214
+ | `DB_USER` | Database username | - |
215
+ | `DB_PASSWD` | Database password | - |
216
+ | `DB_DATABASE` | Database name | `reactpress` |
217
+ | `SERVER_PORT` | Server port | `3002` |
218
+ | `JWT_SECRET` | JWT secret key | - |
219
+ | `CLIENT_SITE_URL` | Client site URL | `http://localhost:3001` |
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 | - |
233
225
 
234
- ### Database Creation
226
+ ## CLI Commands
235
227
 
236
- ```sql
237
- CREATE DATABASE reactpress;
238
- CREATE USER 'reactpress'@'localhost' IDENTIFIED BY 'your_password';
239
- GRANT ALL PRIVILEGES ON reactpress.* TO 'reactpress'@'localhost';
240
- FLUSH PRIVILEGES;
241
- ```
228
+ ```bash
229
+ # Show help
230
+ npx @fecommunity/reactpress-server --help
242
231
 
243
- ## Advanced Usage
232
+ # Start server
233
+ npx @fecommunity/reactpress-server
244
234
 
245
- ### Custom Configuration
235
+ # Start with PM2
236
+ npx @fecommunity/reactpress-server --pm2
246
237
 
247
- ```typescript
248
- import { NestFactory } from '@nestjs/core';
249
- import { AppModule } from '@fecommunity/reactpress-server';
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
- ```
238
+ # Specify port
239
+ npx @fecommunity/reactpress-server --port 3002
265
240
 
266
- ### Plugin Development
241
+ # Enable verbose logging
242
+ npx @fecommunity/reactpress-server --verbose
267
243
 
268
- ```typescript
269
- import { Module } from '@nestjs/common';
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
- }
280
- ```
244
+ # Run database migrations
245
+ npx @fecommunity/reactpress-server --migrate
281
246
 
282
- ## Deployment
247
+ # Seed database with sample data
248
+ npx @fecommunity/reactpress-server --seed
249
+ ```
283
250
 
284
- ### PM2 (Recommended)
251
+ ## Integration with ReactPress Toolkit
285
252
 
286
- ```bash
287
- # Install PM2
288
- npm install -g pm2
253
+ The server automatically generates the OpenAPI specification that powers the ReactPress Toolkit:
289
254
 
290
- # Start with PM2
291
- npm run pm2
255
+ ```typescript
256
+ // The toolkit is automatically generated from this server's API
257
+ import { api, types } from '@fecommunity/reactpress-toolkit';
292
258
 
293
- # Monitor
294
- pm2 monitor
259
+ // All API endpoints are strongly typed
260
+ const articles: types.IArticle[] = await api.article.findAll();
295
261
  ```
296
262
 
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
- ```
263
+ ## Database Schema
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
278
+
279
+ - **JWT Authentication** - Secure token-based authentication with refresh rotation
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
309
300
 
310
- ### Docker Compose
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
- ```
301
+ ```bash
302
+ # Run unit tests
303
+ pnpm run test
335
304
 
336
- ## Integration with Frontend
305
+ # Run integration tests
306
+ pnpm run test:integration
337
307
 
338
- Use with ReactPress client:
308
+ # Run end-to-end tests
309
+ pnpm run test:e2e
339
310
 
340
- ```bash
341
- # Install both server and client
342
- npm install @fecommunity/reactpress-server @fecommunity/reactpress-client @fecommunity/reactpress-config
311
+ # Run tests with coverage
312
+ pnpm run test:cov
343
313
 
344
- # Start server
345
- npx reactpress-server dev
314
+ # Run linting
315
+ pnpm run lint
346
316
 
347
- # In another terminal, start client
348
- npx reactpress-client dev
317
+ # Run formatting
318
+ pnpm run format
319
+
320
+ # Run type checking
321
+ pnpm run type-check
349
322
  ```
350
323
 
351
- ## Troubleshooting
324
+ ## Deployment
352
325
 
353
- ### Common Issues
326
+ ### Production Deployment with PM2
354
327
 
355
- 1. **Database Connection Error**
356
- ```
357
- Error: connect ECONNREFUSED 127.0.0.1:3306
358
- ```
359
- - Ensure MySQL is running
360
- - Check database credentials in `.env`
328
+ ```
329
+ # Start server with PM2
330
+ npx @fecommunity/reactpress-server --pm2
361
331
 
362
- 2. **Port Already in Use**
363
- ```
364
- Error: listen EADDRINUSE :::3002
365
- ```
366
- - Change port in `.env` file or use `-p` option
332
+ # Or build and start manually
333
+ pnpm run build
334
+ pnpm run start:prod
335
+ ```
367
336
 
368
- 3. **JWT Secret Missing**
369
- ```
370
- Error: JWT_SECRET is not defined
371
- ```
372
- - Add `JWT_SECRET=your_secret_key` to `.env`
337
+ ## Monitoring & Logging
373
338
 
374
- ### Debug Mode
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
375
344
 
376
- Start server with debug information:
345
+ ## Support
377
346
 
378
- ```bash
379
- DEBUG=* npx reactpress-server dev
380
- ```
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)
381
351
 
382
352
  ## Contributing
383
353
 
384
- Contributions are welcome! Please feel free to submit a Pull Request.
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
385
359
 
386
360
  ## License
387
361
 
388
- MIT
362
+ MIT License - see [LICENSE](LICENSE) file for details.
389
363
 
390
- ## Links
364
+ ---
391
365
 
392
- - [GitHub Repository](https://github.com/fecommunity/reactpress)
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)
366
+ Built with ❤️ by [FECommunity](https://github.com/fecommunity)