@fecommunity/reactpress-server 1.0.0-beta.4 → 1.0.0-beta.40
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 +81 -342
- package/bin/reactpress-server.js +175 -224
- package/dist/main.d.ts +5 -0
- package/dist/main.js +255 -39
- package/dist/main.js.map +1 -1
- package/dist/modules/setting/setting.service.js +35 -11
- package/dist/modules/setting/setting.service.js.map +1 -1
- package/dist/public/index.html +439 -0
- package/dist/starter.d.ts +1 -0
- package/dist/starter.js +101 -0
- package/dist/starter.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +559 -52
- package/package.json +31 -24
- package/public/index.html +439 -0
- package/dist/bootstrap.d.ts +0 -10
- package/dist/bootstrap.js +0 -57
- package/dist/bootstrap.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FECommunity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,395 +1,134 @@
|
|
|
1
1
|
# @fecommunity/reactpress-server
|
|
2
2
|
|
|
3
|
-
NestJS-based backend API
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
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
|
-
```
|
|
20
|
-
|
|
21
|
-
## Features
|
|
22
|
-
|
|
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
|
|
3
|
+
ReactPress Server - NestJS-based backend API for ReactPress CMS with WordPress-style 5-minute installation.
|
|
31
4
|
|
|
32
5
|
## Quick Start
|
|
33
6
|
|
|
34
|
-
###
|
|
7
|
+
### Installation & Setup
|
|
35
8
|
|
|
36
9
|
```bash
|
|
37
|
-
#
|
|
38
|
-
npx @fecommunity/reactpress-server
|
|
10
|
+
# Regular startup
|
|
11
|
+
npx @fecommunity/reactpress-server
|
|
39
12
|
|
|
40
|
-
#
|
|
41
|
-
reactpress-server
|
|
13
|
+
# PM2 startup
|
|
14
|
+
npx @fecommunity/reactpress-server --pm2
|
|
42
15
|
```
|
|
43
16
|
|
|
44
|
-
|
|
17
|
+
That's it! The command will automatically:
|
|
45
18
|
|
|
46
|
-
|
|
19
|
+
1. **Auto-detect** if configuration exists
|
|
20
|
+
2. **Launch installation wizard** in your browser if no configuration found
|
|
21
|
+
3. **Start the server** immediately after installation
|
|
22
|
+
4. **Open API documentation** at `http://localhost:3002/api`
|
|
47
23
|
|
|
48
|
-
|
|
49
|
-
# Using npx
|
|
50
|
-
npx @fecommunity/reactpress-server dev
|
|
24
|
+
### Features
|
|
51
25
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
26
|
+
- 🚀 **Zero-command installation** - No complex CLI parameters needed
|
|
27
|
+
- 🌍 **WordPress-style setup** - Familiar 5-minute installation process
|
|
28
|
+
- 🔧 **Auto-configuration** - Generates `.env` files automatically
|
|
29
|
+
- 🔌 **Database auto-setup** - Creates MySQL database if it doesn't exist
|
|
30
|
+
- 🎯 **Seamless flow** - From installation to running server in minutes
|
|
31
|
+
- 📖 **Auto-documentation** - Swagger API docs available immediately
|
|
32
|
+
- ⚡ **PM2 support** - Optional PM2 process management for production
|
|
55
33
|
|
|
56
|
-
|
|
34
|
+
### Requirements
|
|
57
35
|
|
|
58
|
-
|
|
36
|
+
- Node.js >= 16.5.0
|
|
37
|
+
- MySQL 5.7+ or 8.0+
|
|
59
38
|
|
|
60
|
-
|
|
61
|
-
# Using npx
|
|
62
|
-
npx @fecommunity/reactpress-server start
|
|
63
|
-
|
|
64
|
-
# Or if installed globally
|
|
65
|
-
reactpress-server start
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## CLI Commands
|
|
69
|
-
|
|
70
|
-
The package includes a powerful CLI for server management:
|
|
39
|
+
### Usage Scenarios
|
|
71
40
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
```
|
|
41
|
+
#### Standalone API Server
|
|
42
|
+
Perfect for:
|
|
43
|
+
- Headless CMS implementation
|
|
44
|
+
- Mobile app backend
|
|
45
|
+
- Microservices architecture
|
|
46
|
+
- Custom frontend integration
|
|
87
47
|
|
|
88
|
-
|
|
48
|
+
#### Full ReactPress Stack
|
|
49
|
+
Use with ReactPress client for complete CMS solution:
|
|
89
50
|
```bash
|
|
90
|
-
#
|
|
91
|
-
npx @fecommunity/reactpress-server
|
|
92
|
-
|
|
93
|
-
# Or if installed globally
|
|
94
|
-
reactpress-server dev [options]
|
|
51
|
+
# Start server
|
|
52
|
+
npx @fecommunity/reactpress-server
|
|
95
53
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
--no-open Don't open browser automatically
|
|
54
|
+
# In another terminal, start client
|
|
55
|
+
npx @fecommunity/reactpress-client
|
|
99
56
|
```
|
|
100
57
|
|
|
101
|
-
###
|
|
102
|
-
```bash
|
|
103
|
-
# Using npx
|
|
104
|
-
npx @fecommunity/reactpress-server start [options]
|
|
105
|
-
|
|
106
|
-
# Or if installed globally
|
|
107
|
-
reactpress-server start [options]
|
|
58
|
+
### PM2 Support
|
|
108
59
|
|
|
109
|
-
|
|
110
|
-
-p, --port <port> Server port (default: 3002)
|
|
111
|
-
```
|
|
60
|
+
ReactPress server supports PM2 process management for production deployments:
|
|
112
61
|
|
|
113
|
-
### Build Project
|
|
114
62
|
```bash
|
|
115
|
-
#
|
|
116
|
-
npx @fecommunity/reactpress-server
|
|
117
|
-
|
|
118
|
-
# Or if installed globally
|
|
119
|
-
reactpress-server build
|
|
63
|
+
# Start with PM2
|
|
64
|
+
npx @fecommunity/reactpress-server --pm2
|
|
120
65
|
```
|
|
121
66
|
|
|
122
|
-
|
|
67
|
+
PM2 features:
|
|
68
|
+
- Automatic process restart on crash
|
|
69
|
+
- Memory monitoring
|
|
70
|
+
- Log management
|
|
71
|
+
- Cluster mode support
|
|
123
72
|
|
|
124
|
-
|
|
73
|
+
### Configuration
|
|
125
74
|
|
|
126
|
-
|
|
127
|
-
# Server Configuration
|
|
128
|
-
SERVER_PORT=3002
|
|
129
|
-
SERVER_API_PREFIX=/api
|
|
130
|
-
NODE_ENV=development
|
|
75
|
+
The installation wizard will create a `.env` file with:
|
|
131
76
|
|
|
132
|
-
|
|
133
|
-
DB_HOST=
|
|
77
|
+
```env
|
|
78
|
+
DB_HOST=127.0.0.1
|
|
134
79
|
DB_PORT=3306
|
|
135
|
-
|
|
136
|
-
|
|
80
|
+
DB_USER=your_username
|
|
81
|
+
DB_PASSWD=your_password
|
|
137
82
|
DB_DATABASE=reactpress
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
157
|
-
|
|
158
|
-
You can also use the server programmatically in your Node.js applications:
|
|
159
|
-
|
|
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
|
|
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
|
|
197
|
-
|
|
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
|
|
203
|
-
|
|
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
|
|
209
|
-
|
|
210
|
-
### File Upload
|
|
211
|
-
- `POST /api/upload/image` - Upload image
|
|
212
|
-
- `POST /api/upload/file` - Upload file
|
|
213
|
-
|
|
214
|
-
## Database Setup
|
|
215
|
-
|
|
216
|
-
### MySQL Installation
|
|
217
|
-
|
|
218
|
-
**Ubuntu/Debian:**
|
|
219
|
-
```bash
|
|
220
|
-
sudo apt update
|
|
221
|
-
sudo apt install mysql-server
|
|
222
|
-
sudo mysql_secure_installation
|
|
83
|
+
CLIENT_SITE_URL=http://localhost:3001
|
|
84
|
+
SERVER_SITE_URL=http://localhost:3002
|
|
223
85
|
```
|
|
224
86
|
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
brew install mysql
|
|
228
|
-
brew services start mysql
|
|
229
|
-
```
|
|
87
|
+
### API Documentation
|
|
230
88
|
|
|
231
|
-
|
|
232
|
-
|
|
89
|
+
Once running, visit `http://localhost:3002/api` for:
|
|
90
|
+
- Interactive Swagger documentation
|
|
91
|
+
- API endpoint explorer
|
|
92
|
+
- Authentication examples
|
|
93
|
+
- Response schemas
|
|
233
94
|
|
|
234
|
-
###
|
|
235
|
-
|
|
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
|
-
```
|
|
242
|
-
|
|
243
|
-
## Advanced Usage
|
|
244
|
-
|
|
245
|
-
### Custom Configuration
|
|
246
|
-
|
|
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
|
-
```
|
|
265
|
-
|
|
266
|
-
### Plugin Development
|
|
267
|
-
|
|
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
|
-
```
|
|
281
|
-
|
|
282
|
-
## Deployment
|
|
283
|
-
|
|
284
|
-
### PM2 (Recommended)
|
|
95
|
+
### Development
|
|
285
96
|
|
|
286
97
|
```bash
|
|
287
|
-
#
|
|
288
|
-
|
|
98
|
+
# Clone repository
|
|
99
|
+
git clone https://github.com/fecommunity/reactpress.git
|
|
100
|
+
cd reactpress/server
|
|
289
101
|
|
|
290
|
-
#
|
|
291
|
-
npm
|
|
292
|
-
|
|
293
|
-
# Monitor
|
|
294
|
-
pm2 monitor
|
|
295
|
-
```
|
|
102
|
+
# Install dependencies
|
|
103
|
+
npm install
|
|
296
104
|
|
|
297
|
-
|
|
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
|
-
```
|
|
105
|
+
# Start development server
|
|
106
|
+
npm run dev
|
|
309
107
|
|
|
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"
|
|
108
|
+
# Start with PM2 (development)
|
|
109
|
+
npm run pm2:start
|
|
334
110
|
```
|
|
335
111
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
Use with ReactPress client:
|
|
112
|
+
### Docker Support
|
|
339
113
|
|
|
340
114
|
```bash
|
|
341
|
-
#
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
# Start server
|
|
345
|
-
npx reactpress-server dev
|
|
346
|
-
|
|
347
|
-
# In another terminal, start client
|
|
348
|
-
npx reactpress-client dev
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
## Troubleshooting
|
|
352
|
-
|
|
353
|
-
### Common Issues
|
|
354
|
-
|
|
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`
|
|
115
|
+
# Using Docker
|
|
116
|
+
docker run -p 3002:3002 @fecommunity/reactpress-server
|
|
361
117
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
Error: listen EADDRINUSE :::3002
|
|
365
|
-
```
|
|
366
|
-
- Change port in `.env` file or use `-p` option
|
|
367
|
-
|
|
368
|
-
3. **JWT Secret Missing**
|
|
369
|
-
```
|
|
370
|
-
Error: JWT_SECRET is not defined
|
|
371
|
-
```
|
|
372
|
-
- Add `JWT_SECRET=your_secret_key` to `.env`
|
|
373
|
-
|
|
374
|
-
### Debug Mode
|
|
375
|
-
|
|
376
|
-
Start server with debug information:
|
|
377
|
-
|
|
378
|
-
```bash
|
|
379
|
-
DEBUG=* npx reactpress-server dev
|
|
118
|
+
# Using docker-compose
|
|
119
|
+
docker-compose up reactpress-server
|
|
380
120
|
```
|
|
381
121
|
|
|
382
|
-
|
|
122
|
+
### Support
|
|
383
123
|
|
|
384
|
-
|
|
124
|
+
- 📖 [Documentation](https://github.com/fecommunity/reactpress)
|
|
125
|
+
- 🐛 [Issues](https://github.com/fecommunity/reactpress/issues)
|
|
126
|
+
- 💬 [Discussions](https://github.com/fecommunity/reactpress/discussions)
|
|
385
127
|
|
|
386
|
-
|
|
128
|
+
### License
|
|
387
129
|
|
|
388
|
-
MIT
|
|
130
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
389
131
|
|
|
390
|
-
|
|
132
|
+
---
|
|
391
133
|
|
|
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)
|
|
134
|
+
Built with ❤️ by [FECommunity](https://github.com/fecommunity)
|