@fecommunity/reactpress-server 1.0.4-beta.0 → 3.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 +278 -307
- package/bin/reactpress-server.js +203 -0
- package/dist/app.module.js +28 -3
- package/dist/app.module.js.map +1 -1
- package/dist/common/api-messages.d.ts +32 -0
- package/dist/common/api-messages.js +36 -0
- package/dist/common/api-messages.js.map +1 -0
- 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/api-key/api-key.controller.d.ts +14 -0
- package/dist/modules/api-key/api-key.controller.js +63 -0
- package/dist/modules/api-key/api-key.controller.js.map +1 -0
- package/dist/modules/api-key/api-key.entity.d.ts +11 -0
- package/dist/modules/api-key/api-key.entity.js +63 -0
- package/dist/modules/api-key/api-key.entity.js.map +1 -0
- package/dist/modules/api-key/api-key.guard.d.ts +7 -0
- package/dist/modules/api-key/api-key.guard.js +40 -0
- package/dist/modules/api-key/api-key.guard.js.map +1 -0
- package/dist/modules/api-key/api-key.module.d.ts +2 -0
- package/dist/modules/api-key/api-key.module.js +28 -0
- package/dist/modules/api-key/api-key.module.js.map +1 -0
- package/dist/modules/api-key/api-key.service.d.ts +15 -0
- package/dist/modules/api-key/api-key.service.js +81 -0
- package/dist/modules/api-key/api-key.service.js.map +1 -0
- package/dist/modules/article/article-revision.entity.d.ts +11 -0
- package/dist/modules/article/article-revision.entity.js +53 -0
- package/dist/modules/article/article-revision.entity.js.map +1 -0
- package/dist/modules/article/article.controller.d.ts +6 -1
- package/dist/modules/article/article.controller.js +45 -1
- package/dist/modules/article/article.controller.js.map +1 -1
- package/dist/modules/article/article.entity.d.ts +1 -0
- package/dist/modules/article/article.entity.js +5 -0
- package/dist/modules/article/article.entity.js.map +1 -1
- package/dist/modules/article/article.module.js +14 -2
- package/dist/modules/article/article.module.js.map +1 -1
- package/dist/modules/article/article.service.d.ts +9 -1
- package/dist/modules/article/article.service.js +59 -5
- package/dist/modules/article/article.service.js.map +1 -1
- package/dist/modules/article/scheduled-publish.service.d.ts +13 -0
- package/dist/modules/article/scheduled-publish.service.js +65 -0
- package/dist/modules/article/scheduled-publish.service.js.map +1 -0
- package/dist/modules/auth/auth.service.js +4 -3
- package/dist/modules/auth/auth.service.js.map +1 -1
- package/dist/modules/auth/jwt-auth.guard.js +2 -1
- package/dist/modules/auth/jwt-auth.guard.js.map +1 -1
- package/dist/modules/auth/jwt.strategy.js +2 -1
- package/dist/modules/auth/jwt.strategy.js.map +1 -1
- package/dist/modules/category/category.service.js +3 -2
- package/dist/modules/category/category.service.js.map +1 -1
- package/dist/modules/comment/comment.module.js +10 -1
- package/dist/modules/comment/comment.module.js.map +1 -1
- package/dist/modules/comment/comment.service.d.ts +3 -1
- package/dist/modules/comment/comment.service.js +15 -5
- package/dist/modules/comment/comment.service.js.map +1 -1
- package/dist/modules/health/health.controller.d.ts +11 -0
- package/dist/modules/health/health.controller.js +57 -0
- package/dist/modules/health/health.controller.js.map +1 -0
- package/dist/modules/health/health.module.d.ts +2 -0
- package/dist/modules/health/health.module.js +20 -0
- package/dist/modules/health/health.module.js.map +1 -0
- package/dist/modules/knowledge/knowledge.service.js +3 -2
- package/dist/modules/knowledge/knowledge.service.js.map +1 -1
- package/dist/modules/page/page.service.js +2 -1
- package/dist/modules/page/page.service.js.map +1 -1
- package/dist/modules/setting/setting.constant.d.ts +2 -3
- package/dist/modules/setting/setting.constant.js +4 -3
- package/dist/modules/setting/setting.constant.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/modules/smtp/smtp.service.js +2 -1
- package/dist/modules/smtp/smtp.service.js.map +1 -1
- package/dist/modules/tag/tag.service.js +3 -2
- package/dist/modules/tag/tag.service.js.map +1 -1
- package/dist/modules/user/user.controller.js +4 -3
- package/dist/modules/user/user.controller.js.map +1 -1
- package/dist/modules/user/user.service.js +10 -9
- package/dist/modules/user/user.service.js.map +1 -1
- package/dist/modules/webhook/webhook.controller.d.ts +12 -0
- package/dist/modules/webhook/webhook.controller.js +63 -0
- package/dist/modules/webhook/webhook.controller.js.map +1 -0
- package/dist/modules/webhook/webhook.entity.d.ts +9 -0
- package/dist/modules/webhook/webhook.entity.js +54 -0
- package/dist/modules/webhook/webhook.entity.js.map +1 -0
- package/dist/modules/webhook/webhook.module.d.ts +2 -0
- package/dist/modules/webhook/webhook.module.js +27 -0
- package/dist/modules/webhook/webhook.module.js.map +1 -0
- package/dist/modules/webhook/webhook.service.d.ts +16 -0
- package/dist/modules/webhook/webhook.service.js +97 -0
- package/dist/modules/webhook/webhook.service.js.map +1 -0
- 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 +4963 -3719
- package/dist/utils/oss.util.js +2 -1
- package/dist/utils/oss.util.js.map +1 -1
- package/package.json +42 -32
- 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,366 @@
|
|
|
1
1
|
# @fecommunity/reactpress-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ReactPress Server - NestJS 10 backend API for ReactPress CMS with simple 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 @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
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
### 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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
62
|
-
npx @fecommunity/reactpress-server
|
|
70
|
+
# Start server
|
|
71
|
+
npx @fecommunity/reactpress-server
|
|
63
72
|
|
|
64
|
-
#
|
|
65
|
-
reactpress-
|
|
73
|
+
# In another terminal, start client
|
|
74
|
+
npx @fecommunity/reactpress-client
|
|
66
75
|
```
|
|
67
76
|
|
|
68
|
-
##
|
|
77
|
+
## API Modules
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
ReactPress Server provides comprehensive API modules:
|
|
71
80
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
94
|
-
reactpress-server dev [options]
|
|
94
|
+
## PM2 Support
|
|
95
95
|
|
|
96
|
-
|
|
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
|
-
#
|
|
104
|
-
npx @fecommunity/reactpress-server
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
119
|
-
reactpress-server build
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Environment Configuration
|
|
110
|
+
## Configuration
|
|
123
111
|
|
|
124
|
-
|
|
112
|
+
The installation wizard will create a `.env` file with:
|
|
125
113
|
|
|
126
114
|
```env
|
|
127
|
-
#
|
|
128
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
DB_DATABASE=
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
#
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
##
|
|
146
|
+
## API Documentation
|
|
157
147
|
|
|
158
|
-
|
|
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
|
-
|
|
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
|
-
|
|
158
|
+
```bash
|
|
159
|
+
# Clone repository
|
|
160
|
+
git clone https://github.com/fecommunity/reactpress.git
|
|
161
|
+
cd reactpress/server
|
|
179
162
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
- `POST /api/auth/register` - User registration
|
|
183
|
-
- `GET /api/auth/profile` - Get user profile
|
|
163
|
+
# Install dependencies
|
|
164
|
+
pnpm install
|
|
184
165
|
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
193
|
-
|
|
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
|
-
|
|
199
|
-
|
|
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
|
-
|
|
205
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
- `POST /api/upload/file` - Upload file
|
|
178
|
+
# Run tests with coverage
|
|
179
|
+
pnpm run test:cov
|
|
213
180
|
|
|
214
|
-
|
|
181
|
+
# Run end-to-end tests
|
|
182
|
+
pnpm run test:e2e
|
|
183
|
+
```
|
|
215
184
|
|
|
216
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
226
|
+
## CLI Commands
|
|
235
227
|
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
232
|
+
# Start server
|
|
233
|
+
npx @fecommunity/reactpress-server
|
|
244
234
|
|
|
245
|
-
|
|
235
|
+
# Start with PM2
|
|
236
|
+
npx @fecommunity/reactpress-server --pm2
|
|
246
237
|
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
241
|
+
# Enable verbose logging
|
|
242
|
+
npx @fecommunity/reactpress-server --verbose
|
|
267
243
|
|
|
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
|
-
}
|
|
280
|
-
```
|
|
244
|
+
# Run database migrations
|
|
245
|
+
npx @fecommunity/reactpress-server --migrate
|
|
281
246
|
|
|
282
|
-
|
|
247
|
+
# Seed database with sample data
|
|
248
|
+
npx @fecommunity/reactpress-server --seed
|
|
249
|
+
```
|
|
283
250
|
|
|
284
|
-
|
|
251
|
+
## Integration with ReactPress Toolkit
|
|
285
252
|
|
|
286
|
-
|
|
287
|
-
# Install PM2
|
|
288
|
-
npm install -g pm2
|
|
253
|
+
The server automatically generates the OpenAPI specification that powers the ReactPress Toolkit:
|
|
289
254
|
|
|
290
|
-
|
|
291
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
// The toolkit is automatically generated from this server's API
|
|
257
|
+
import { api, types } from '@fecommunity/reactpress-toolkit';
|
|
292
258
|
|
|
293
|
-
|
|
294
|
-
|
|
259
|
+
// All API endpoints are strongly typed
|
|
260
|
+
const articles: types.IArticle[] = await api.article.findAll();
|
|
295
261
|
```
|
|
296
262
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
305
|
+
# Run integration tests
|
|
306
|
+
pnpm run test:integration
|
|
337
307
|
|
|
338
|
-
|
|
308
|
+
# Run end-to-end tests
|
|
309
|
+
pnpm run test:e2e
|
|
339
310
|
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
#
|
|
345
|
-
|
|
314
|
+
# Run linting
|
|
315
|
+
pnpm run lint
|
|
346
316
|
|
|
347
|
-
#
|
|
348
|
-
|
|
317
|
+
# Run formatting
|
|
318
|
+
pnpm run format
|
|
319
|
+
|
|
320
|
+
# Run type checking
|
|
321
|
+
pnpm run type-check
|
|
349
322
|
```
|
|
350
323
|
|
|
351
|
-
##
|
|
324
|
+
## Deployment
|
|
352
325
|
|
|
353
|
-
###
|
|
326
|
+
### Production Deployment with PM2
|
|
354
327
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
369
|
-
```
|
|
370
|
-
Error: JWT_SECRET is not defined
|
|
371
|
-
```
|
|
372
|
-
- Add `JWT_SECRET=your_secret_key` to `.env`
|
|
337
|
+
## Monitoring & Logging
|
|
373
338
|
|
|
374
|
-
|
|
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
|
-
|
|
345
|
+
## Support
|
|
377
346
|
|
|
378
|
-
|
|
379
|
-
|
|
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
|
-
|
|
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
|
-
|
|
364
|
+
---
|
|
391
365
|
|
|
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)
|
|
366
|
+
Built with ❤️ by [FECommunity](https://github.com/fecommunity)
|