@fecommunity/reactpress-server 1.0.5-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.
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
@@ -1,302 +1,203 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { program } = require('commander');
4
- const { execSync } = require('child_process');
3
+ /**
4
+ * ReactPress Server CLI Entry Point
5
+ * This script allows starting the ReactPress server via npx
6
+ * Supports both regular and PM2 startup modes
7
+ */
8
+
5
9
  const path = require('path');
6
10
  const fs = require('fs');
7
- const chalk = require('chalk');
8
- const inquirer = require('inquirer');
11
+ const { spawn, spawnSync } = require('child_process');
9
12
 
10
- program
11
- .name('@reactpress/server')
12
- .description('ReactPress Server CLI')
13
- .version('1.0.0');
13
+ // Capture the original working directory where npx was executed
14
+ // BUT prioritize the REACTPRESS_ORIGINAL_CWD environment variable if it exists
15
+ // This ensures consistency when running via pnpm dev from root directory
16
+ const originalCwd = process.env.REACTPRESS_ORIGINAL_CWD || process.cwd();
14
17
 
15
- // Init command - 初始化服务器配置
16
- program
17
- .command('init')
18
- .description('Initialize ReactPress server configuration')
19
- .option('-d, --database <type>', 'Database type (mysql|postgres)', 'mysql')
20
- .option('-p, --port <port>', 'Server port', '3002')
21
- .option('--skip-db-setup', 'Skip database setup')
22
- .action(async (options) => {
23
- console.log(chalk.blue('🚀 Initializing ReactPress Server...\n'));
24
-
25
- const cwd = process.cwd();
26
- const envPath = path.join(cwd, '.env');
27
-
28
- // 检查.env文件是否已存在
29
- if (fs.existsSync(envPath)) {
30
- const { overwrite } = await inquirer.prompt([
31
- {
32
- type: 'confirm',
33
- name: 'overwrite',
34
- message: 'Configuration file (.env) already exists. Overwrite?',
35
- default: false
36
- }
37
- ]);
38
-
39
- if (!overwrite) {
40
- console.log(chalk.yellow('⚠️ Initialization cancelled.'));
41
- process.exit(0);
42
- }
43
- }
44
-
45
- // 收集配置信息
46
- console.log(chalk.cyan('📋 Please provide the following configuration:\n'));
47
-
48
- const config = await inquirer.prompt([
49
- {
50
- type: 'input',
51
- name: 'DB_HOST',
52
- message: 'Database host:',
53
- default: 'localhost'
54
- },
55
- {
56
- type: 'input',
57
- name: 'DB_PORT',
58
- message: 'Database port:',
59
- default: options.database === 'postgres' ? '5432' : '3306'
60
- },
61
- {
62
- type: 'input',
63
- name: 'DB_USERNAME',
64
- message: 'Database username:',
65
- default: 'root'
66
- },
67
- {
68
- type: 'password',
69
- name: 'DB_PASSWORD',
70
- message: 'Database password:',
71
- mask: '*'
72
- },
73
- {
74
- type: 'input',
75
- name: 'DB_DATABASE',
76
- message: 'Database name:',
77
- default: 'reactpress'
78
- },
79
- {
80
- type: 'input',
81
- name: 'SERVER_PORT',
82
- message: 'Server port:',
83
- default: options.port
84
- },
85
- {
86
- type: 'input',
87
- name: 'JWT_SECRET',
88
- message: 'JWT secret (leave empty to generate):',
89
- default: ''
90
- },
91
- {
92
- type: 'input',
93
- name: 'ADMIN_USER',
94
- message: 'Admin username:',
95
- default: 'admin'
96
- },
97
- {
98
- type: 'password',
99
- name: 'ADMIN_PASSWD',
100
- message: 'Admin password:',
101
- default: 'admin',
102
- mask: '*'
103
- }
104
- ]);
105
-
106
- // 如果没有提供JWT密钥则生成一个
107
- if (!config.JWT_SECRET) {
108
- config.JWT_SECRET = require('crypto').randomBytes(32).toString('hex');
109
- console.log(chalk.green('🔐 Generated JWT secret'));
110
- }
111
-
112
- // 创建.env文件
113
- const envContent = `# ReactPress Server Configuration
114
- # Generated on ${new Date().toISOString()}
18
+ // Get command line arguments
19
+ const args = process.argv.slice(2);
20
+ const usePM2 = args.includes('--pm2');
21
+ const showHelp = args.includes('--help') || args.includes('-h');
115
22
 
116
- # Database Configuration
117
- DB_TYPE=${options.database}
118
- DB_HOST=${config.DB_HOST}
119
- DB_PORT=${config.DB_PORT}
120
- DB_USERNAME=${config.DB_USERNAME}
121
- DB_PASSWORD=${config.DB_PASSWORD}
122
- DB_DATABASE=${config.DB_DATABASE}
23
+ // Show help if requested
24
+ if (showHelp) {
25
+ console.log(`
26
+ ReactPress Server - NestJS-based backend API for ReactPress CMS
123
27
 
124
- # Server Configuration
125
- SERVER_PORT=${config.SERVER_PORT}
126
- SERVER_API_PREFIX=/api
28
+ Usage:
29
+ reactpress-server [options]
30
+ (通常由 reactpress-cli start 调用)
127
31
 
128
- # Security
129
- JWT_SECRET=${config.JWT_SECRET}
130
- ADMIN_USER=${config.ADMIN_USER}
131
- ADMIN_PASSWD=${config.ADMIN_PASSWD}
32
+ Options:
33
+ --pm2 Start server with PM2 process manager
34
+ --help, -h Show this help message
132
35
 
133
- # Environment
134
- NODE_ENV=development
135
- `;
136
-
137
- fs.writeFileSync(envPath, envContent);
138
- console.log(chalk.green('✅ Configuration saved to .env file'));
139
-
140
- if (!options.skipDbSetup) {
141
- console.log(chalk.yellow('\n🗄️ Setting up database...'));
142
- console.log(chalk.gray(`Please ensure your ${options.database} server is running and create the database:`));
143
- console.log(chalk.cyan(`CREATE DATABASE ${config.DB_DATABASE};`));
144
- console.log(chalk.gray('Then run: npx @reactpress/server start'));
145
- }
146
-
147
- console.log(chalk.green('\n🎉 ReactPress Server initialized successfully!'));
148
- console.log(chalk.cyan('\nNext steps:'));
149
- console.log(chalk.gray('1. Start the server: npx @reactpress/server start'));
150
- console.log(chalk.gray('2. Visit API: http://localhost:' + config.SERVER_PORT + '/api'));
151
- console.log(chalk.gray('3. API docs: http://localhost:' + config.SERVER_PORT + '/api (Swagger UI)'));
152
- });
36
+ Examples:
37
+ node bin/reactpress-server.js # Start server normally
38
+ node bin/reactpress-server.js --pm2 # Start server with PM2
39
+ `);
40
+ process.exit(0);
41
+ }
153
42
 
154
- // Start command - 启动服务器
155
- program
156
- .command('start')
157
- .description('Start ReactPress server')
158
- .option('-p, --port <port>', 'Server port')
159
- .option('-d, --dev', 'Start in development mode')
160
- .option('--watch', 'Watch for file changes (dev mode)')
161
- .action(async (options) => {
162
- console.log(chalk.blue('🚀 Starting ReactPress Server...\n'));
163
-
164
- const cwd = process.cwd();
165
- const envPath = path.join(cwd, '.env');
166
-
167
- // 检查.env文件是否存在
168
- if (!fs.existsSync(envPath)) {
169
- console.log(chalk.red('❌ Configuration file (.env) not found!'));
170
- console.log(chalk.yellow('Please run: npx @reactpress/server init'));
171
- process.exit(1);
172
- }
173
-
174
- // 检查是否在项目根目录(有server目录)
175
- const serverPath = path.join(cwd, 'server');
176
- const hasServerDir = fs.existsSync(serverPath);
177
-
178
- let serverMainPath;
179
- if (hasServerDir) {
180
- // 在项目根目录,使用相对路径
181
- serverMainPath = path.join(serverPath, 'dist', 'main.js');
182
- const packageDir = serverPath;
183
-
184
- // 检查构建文件是否存在
185
- if (!fs.existsSync(serverMainPath)) {
186
- console.log(chalk.yellow('⚠️ Built server not found, building...'));
187
- try {
188
- execSync('pnpm run build:server', { cwd: cwd, stdio: 'inherit' });
189
- } catch (error) {
190
- console.log(chalk.red('❌ Build failed'));
191
- process.exit(1);
192
- }
193
- }
194
- } else {
195
- // 可能在独立安装的@reactpress/server包中
196
- try {
197
- const serverPackagePath = require.resolve('@reactpress/server/package.json');
198
- const serverPackageDir = path.dirname(serverPackagePath);
199
- serverMainPath = path.join(serverPackageDir, 'dist', 'main.js');
200
- } catch (error) {
201
- console.log(chalk.red('❌ ReactPress server package not found!'));
202
- console.log(chalk.yellow('Please install: npm install @reactpress/server'));
203
- process.exit(1);
204
- }
205
- }
206
-
207
- // 设置环境变量
208
- const env = {
209
- ...process.env,
210
- NODE_ENV: options.dev ? 'development' : 'production'
211
- };
212
-
213
- if (options.port) {
214
- env.SERVER_PORT = options.port;
215
- }
216
-
43
+ // Get the directory where this script is located
44
+ const binDir = __dirname;
45
+ const serverDir = path.join(binDir, '..');
46
+ const distPath = path.join(serverDir, 'dist', 'main.js');
47
+ const ecosystemPath = path.join(serverDir, 'ecosystem.config.js');
48
+
49
+ // Function to check if PM2 is installed
50
+ function isPM2Installed() {
51
+ try {
52
+ require.resolve('pm2');
53
+ return true;
54
+ } catch (e) {
55
+ // Check if PM2 is installed globally
217
56
  try {
218
- if (options.dev || options.watch) {
219
- console.log(chalk.yellow('🔄 Starting in development mode...'));
220
- if (hasServerDir) {
221
- execSync('pnpm run dev:server', {
222
- cwd: cwd,
223
- stdio: 'inherit',
224
- env
225
- });
226
- } else {
227
- console.log(chalk.yellow('⚠️ Development mode requires server source code'));
228
- console.log(chalk.cyan('Starting in production mode instead...'));
229
- execSync(`node ${serverMainPath}`, {
230
- cwd: process.cwd(),
231
- stdio: 'inherit',
232
- env
233
- });
234
- }
235
- } else {
236
- console.log(chalk.green('🌟 Starting in production mode...'));
237
- execSync(`node ${serverMainPath}`, {
238
- cwd: process.cwd(),
239
- stdio: 'inherit',
240
- env
241
- });
242
- }
243
- } catch (error) {
244
- console.log(chalk.red('❌ Failed to start server'));
245
- process.exit(1);
57
+ spawnSync('pm2', ['--version'], { stdio: 'ignore' });
58
+ return true;
59
+ } catch (e) {
60
+ return false;
246
61
  }
62
+ }
63
+ }
64
+
65
+ // Function to install PM2
66
+ function installPM2() {
67
+ console.log('[ReactPress Server] Installing PM2...');
68
+ const installResult = spawnSync('npm', ['install', 'pm2', '--no-save'], {
69
+ stdio: 'inherit',
70
+ cwd: serverDir
247
71
  });
72
+
73
+ if (installResult.status !== 0) {
74
+ console.error('[ReactPress Server] Failed to install PM2');
75
+ return false;
76
+ }
77
+
78
+ return true;
79
+ }
248
80
 
249
- // Build command - 构建服务器
250
- program
251
- .command('build')
252
- .description('Build ReactPress server')
253
- .action(() => {
254
- console.log(chalk.blue('🔨 Building ReactPress Server...\n'));
255
-
256
- const cwd = process.cwd();
257
- const serverPath = path.join(cwd, 'server');
258
-
259
- if (!fs.existsSync(serverPath)) {
260
- console.log(chalk.red('❌ Server directory not found!'));
261
- console.log(chalk.yellow('This command should be run from the project root directory.'));
81
+ // Function to start with PM2
82
+ function startWithPM2() {
83
+ // Check if PM2 is installed
84
+ if (!isPM2Installed()) {
85
+ // Try to install PM2
86
+ if (!installPM2()) {
87
+ console.error('[ReactPress Server] Cannot start with PM2');
262
88
  process.exit(1);
263
89
  }
90
+ }
91
+
92
+ // Check if the server is built
93
+ if (!fs.existsSync(distPath)) {
94
+ console.log('[ReactPress Server] Server not built yet. Building...');
95
+
96
+ // Try to build the server
97
+ const buildResult = spawnSync('npm', ['run', 'build'], {
98
+ stdio: 'inherit',
99
+ cwd: serverDir
100
+ });
264
101
 
265
- try {
266
- execSync('pnpm run build:server', {
267
- cwd: cwd,
268
- stdio: 'inherit'
269
- });
270
- console.log(chalk.green('✅ Build completed successfully!'));
271
- } catch (error) {
272
- console.log(chalk.red('❌ Build failed'));
102
+ if (buildResult.status !== 0) {
103
+ console.error('[ReactPress Server] Failed to build server');
273
104
  process.exit(1);
274
105
  }
275
- });
276
-
277
- // Dev command - 开发模式启动
278
- program
279
- .command('dev')
280
- .description('Start server in development mode')
281
- .option('-p, --port <port>', 'Server port')
282
- .action((options) => {
283
- console.log(chalk.blue('🔄 Starting ReactPress Server in development mode...\n'));
284
-
285
- // 调用start命令的dev模式
286
- const args = ['start', '--dev'];
287
- if (options.port) {
288
- args.push('--port', options.port);
106
+ }
107
+
108
+ console.log('[ReactPress Server] Starting with PM2...');
109
+
110
+ // Use ecosystem.config.js if it exists, otherwise use direct command
111
+ let pm2Command = 'pm2';
112
+ try {
113
+ // Try to resolve PM2 path
114
+ pm2Command = path.join(serverDir, 'node_modules', '.bin', 'pm2');
115
+ if (!fs.existsSync(pm2Command)) {
116
+ pm2Command = 'pm2';
289
117
  }
118
+ } catch (e) {
119
+ pm2Command = 'pm2';
120
+ }
121
+
122
+ // Check if ecosystem.config.js exists
123
+ if (fs.existsSync(ecosystemPath)) {
124
+ const pm2 = spawn(pm2Command, ['start', ecosystemPath], {
125
+ stdio: 'inherit',
126
+ cwd: serverDir
127
+ });
290
128
 
291
- // 重新调用当前脚本
292
- const child = require('child_process').spawn('node', [__filename, ...args], {
129
+ pm2.on('close', (code) => {
130
+ console.log(`[ReactPress Server] PM2 process exited with code ${code}`);
131
+ process.exit(code);
132
+ });
133
+
134
+ pm2.on('error', (error) => {
135
+ console.error('[ReactPress Server] Failed to start with PM2:', error);
136
+ process.exit(1);
137
+ });
138
+ } else {
139
+ // Fallback to direct start
140
+ const pm2 = spawn(pm2Command, ['start', distPath, '--name', 'reactpress-server'], {
293
141
  stdio: 'inherit',
294
- env: process.env
142
+ cwd: serverDir
295
143
  });
296
144
 
297
- child.on('exit', (code) => {
145
+ pm2.on('close', (code) => {
146
+ console.log(`[ReactPress Server] PM2 process exited with code ${code}`);
298
147
  process.exit(code);
299
148
  });
300
- });
149
+
150
+ pm2.on('error', (error) => {
151
+ console.error('[ReactPress Server] Failed to start with PM2:', error);
152
+ process.exit(1);
153
+ });
154
+ }
155
+ }
156
+
157
+ // Function to start with regular Node.js
158
+ function startWithNode() {
159
+ // Check if the server is built
160
+ if (!fs.existsSync(distPath)) {
161
+ console.log('[ReactPress Server] Server not built yet. Building...');
162
+
163
+ // Try to build the server
164
+ const buildResult = spawnSync('npm', ['run', 'build'], {
165
+ stdio: 'inherit',
166
+ cwd: serverDir
167
+ });
168
+
169
+ if (buildResult.status !== 0) {
170
+ console.error('[ReactPress Server] Failed to build server');
171
+ process.exit(1);
172
+ }
173
+ }
174
+
175
+ // ONLY set the environment variable if it's not already set
176
+ // This preserves the value set by set-env.js when running pnpm dev from root
177
+ if (!process.env.REACTPRESS_ORIGINAL_CWD) {
178
+ process.env.REACTPRESS_ORIGINAL_CWD = originalCwd;
179
+ } else {
180
+ console.log(`[ReactPress Server] Using existing REACTPRESS_ORIGINAL_CWD: ${process.env.REACTPRESS_ORIGINAL_CWD}`);
181
+ }
182
+
183
+ // Change to the server directory
184
+ process.chdir(serverDir);
185
+
186
+ // Set environment variables
187
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production';
188
+
189
+ // Import and run the server
190
+ try {
191
+ require(distPath);
192
+ } catch (error) {
193
+ console.error('[ReactPress Server] Failed to start server:', error);
194
+ process.exit(1);
195
+ }
196
+ }
301
197
 
302
- program.parse();
198
+ // Main execution
199
+ if (usePM2) {
200
+ startWithPM2();
201
+ } else {
202
+ startWithNode();
203
+ }
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AppModule = void 0;
10
- const reactpress_config_1 = require("@fecommunity/reactpress-config");
10
+ const reactpress_toolkit_1 = require("../../toolkit/dist");
11
11
  const common_1 = require("@nestjs/common");
12
12
  const config_1 = require("@nestjs/config");
13
13
  const typeorm_1 = require("@nestjs/typeorm");
@@ -36,18 +36,40 @@ const user_entity_1 = require("./modules/user/user.entity");
36
36
  const user_module_1 = require("./modules/user/user.module");
37
37
  const view_entity_1 = require("./modules/view/view.entity");
38
38
  const view_module_1 = require("./modules/view/view.module");
39
+ const api_key_entity_1 = require("./modules/api-key/api-key.entity");
40
+ const api_key_module_1 = require("./modules/api-key/api-key.module");
41
+ const article_revision_entity_1 = require("./modules/article/article-revision.entity");
42
+ const health_module_1 = require("./modules/health/health.module");
43
+ const webhook_entity_1 = require("./modules/webhook/webhook.entity");
44
+ const webhook_module_1 = require("./modules/webhook/webhook.module");
39
45
  let AppModule = class AppModule {
40
46
  };
41
47
  AppModule = __decorate([
42
48
  common_1.Module({
43
49
  imports: [
44
- config_1.ConfigModule.forRoot({ isGlobal: true, envFilePath: [reactpress_config_1.file] }),
50
+ config_1.ConfigModule.forRoot({ isGlobal: true, envFilePath: [reactpress_toolkit_1.config.file] }),
45
51
  typeorm_1.TypeOrmModule.forRootAsync({
46
52
  imports: [config_1.ConfigModule],
47
53
  inject: [config_1.ConfigService],
48
54
  useFactory: async (configService) => ({
49
55
  type: 'mysql',
50
- entities: [user_entity_1.User, file_entity_1.File, knowledge_entity_1.Knowledge, article_entity_1.Article, category_entity_1.Category, tag_entity_1.Tag, comment_entity_1.Comment, setting_entity_1.Setting, smtp_entity_1.SMTP, page_entity_1.Page, view_entity_1.View, search_entity_1.Search],
56
+ entities: [
57
+ user_entity_1.User,
58
+ file_entity_1.File,
59
+ knowledge_entity_1.Knowledge,
60
+ article_entity_1.Article,
61
+ article_revision_entity_1.ArticleRevision,
62
+ category_entity_1.Category,
63
+ tag_entity_1.Tag,
64
+ comment_entity_1.Comment,
65
+ setting_entity_1.Setting,
66
+ smtp_entity_1.SMTP,
67
+ page_entity_1.Page,
68
+ view_entity_1.View,
69
+ search_entity_1.Search,
70
+ api_key_entity_1.ApiKey,
71
+ webhook_entity_1.Webhook,
72
+ ],
51
73
  host: configService.get('DB_HOST', '0.0.0.0'),
52
74
  port: configService.get('DB_PORT', 3306),
53
75
  username: configService.get('DB_USER', 'root'),
@@ -71,6 +93,9 @@ AppModule = __decorate([
71
93
  page_module_1.PageModule,
72
94
  view_module_1.ViewModule,
73
95
  search_module_1.SearchModule,
96
+ health_module_1.HealthModule,
97
+ api_key_module_1.ApiKeyModule,
98
+ webhook_module_1.WebhookModule,
74
99
  ],
75
100
  controllers: [],
76
101
  providers: [],
@@ -1 +1 @@
1
- {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AACA,sEAAqE;AACrE,2CAAwC;AACxC,2CAA6D;AAC7D,6CAAgD;AAEhD,qEAA2D;AAE3D,qEAAiE;AAEjE,4DAAwD;AACxD,wEAA8D;AAE9D,wEAAoE;AACpE,qEAA2D;AAE3D,qEAAiE;AACjE,4DAAkD;AAElD,4DAAwD;AACxD,2EAAiE;AAEjE,2EAAuE;AACvE,4DAAkD;AAElD,4DAAwD;AAExD,kEAAwD;AACxD,kEAA8D;AAC9D,qEAA2D;AAE3D,qEAAiE;AACjE,4DAAkD;AAElD,4DAAwD;AACxD,yDAA+C;AAE/C,yDAAqD;AACrD,4DAAkD;AAElD,4DAAwD;AACxD,4DAAkD;AAElD,4DAAwD;AAsCxD,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IApCrB,eAAM,CAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,wBAAW,CAAC,EAAE,CAAC;YACpE,uBAAa,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,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AAa,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;oBAChD,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC;oBACxD,OAAO,EAAE,SAAS;oBAClB,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,IAAI;iBAClB,CAAC;aACH,CAAC;YACF,wBAAU;YACV,wBAAU;YACV,sBAAS;YACT,8BAAa;YACb,kCAAe;YACf,gCAAc;YACd,8BAAa;YACb,8BAAa;YACb,wBAAU;YACV,wBAAU;YACV,wBAAU;YACV,wBAAU;YACV,4BAAY;YACZ,4BAAY;YACZ,6BAAY;YACZ,8BAAa;SACd;QACD,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
@@ -0,0 +1,32 @@
1
+ export declare const ApiMsg: {
2
+ readonly AUTH_FAILED: "Authentication failed";
3
+ readonly MISSING_API_KEY: "Missing API Key";
4
+ readonly INVALID_API_KEY: "Invalid API Key";
5
+ readonly API_KEY_NOT_FOUND: "API Key not found";
6
+ readonly API_KEY_MISSING_READ: "API Key missing read permission";
7
+ readonly MISSING_PARAMS: "Missing required parameters";
8
+ readonly EMAIL_SEND_FAILED: "Failed to send email";
9
+ readonly OSS_CONFIG_INCOMPLETE: "OSS configuration is incomplete";
10
+ readonly WEBHOOK_NOT_FOUND: "Webhook not found";
11
+ readonly USERNAME_PASSWORD_REQUIRED: "Username and password are required";
12
+ readonly USERNAME_INVALID: "Username cannot contain spaces or invalid characters";
13
+ readonly USER_EXISTS: "User already exists";
14
+ readonly INVALID_CREDENTIALS: "Invalid username or password";
15
+ readonly USER_LOCKED: "User is locked and cannot sign in";
16
+ readonly FORBIDDEN: "You do not have permission for this action";
17
+ readonly UNAUTHORIZED: "Unauthorized";
18
+ readonly FORBIDDEN_ACTION: "Forbidden";
19
+ readonly ARTICLE_TITLE_EXISTS: "Article title already exists";
20
+ readonly REVISION_NOT_FOUND: "Revision not found";
21
+ readonly TAG_EXISTS: "Tag already exists";
22
+ readonly CATEGORY_EXISTS: "Category already exists";
23
+ readonly PAGE_EXISTS: "Page already exists";
24
+ readonly KNOWLEDGE_EXISTS: "Knowledge base already exists";
25
+ readonly INVALID_KNOWLEDGE_SECTION: "Invalid knowledge section";
26
+ readonly DELETE_HAS_ARTICLES: "Delete failed: related articles may exist";
27
+ readonly GITHUB_CODE_REQUIRED: "GitHub authorization code is required";
28
+ readonly GITHUB_EMAIL_REQUIRED: "Public email is required for GitHub sign-in";
29
+ readonly EMAIL_NEW_COMMENT: "New comment notification";
30
+ readonly EMAIL_COMMENT_REPLY: "Comment reply notification";
31
+ readonly EMAIL_GITHUB_LOGIN: "GitHub sign-in notification";
32
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiMsg = void 0;
4
+ exports.ApiMsg = {
5
+ AUTH_FAILED: 'Authentication failed',
6
+ MISSING_API_KEY: 'Missing API Key',
7
+ INVALID_API_KEY: 'Invalid API Key',
8
+ API_KEY_NOT_FOUND: 'API Key not found',
9
+ API_KEY_MISSING_READ: 'API Key missing read permission',
10
+ MISSING_PARAMS: 'Missing required parameters',
11
+ EMAIL_SEND_FAILED: 'Failed to send email',
12
+ OSS_CONFIG_INCOMPLETE: 'OSS configuration is incomplete',
13
+ WEBHOOK_NOT_FOUND: 'Webhook not found',
14
+ USERNAME_PASSWORD_REQUIRED: 'Username and password are required',
15
+ USERNAME_INVALID: 'Username cannot contain spaces or invalid characters',
16
+ USER_EXISTS: 'User already exists',
17
+ INVALID_CREDENTIALS: 'Invalid username or password',
18
+ USER_LOCKED: 'User is locked and cannot sign in',
19
+ FORBIDDEN: 'You do not have permission for this action',
20
+ UNAUTHORIZED: 'Unauthorized',
21
+ FORBIDDEN_ACTION: 'Forbidden',
22
+ ARTICLE_TITLE_EXISTS: 'Article title already exists',
23
+ REVISION_NOT_FOUND: 'Revision not found',
24
+ TAG_EXISTS: 'Tag already exists',
25
+ CATEGORY_EXISTS: 'Category already exists',
26
+ PAGE_EXISTS: 'Page already exists',
27
+ KNOWLEDGE_EXISTS: 'Knowledge base already exists',
28
+ INVALID_KNOWLEDGE_SECTION: 'Invalid knowledge section',
29
+ DELETE_HAS_ARTICLES: 'Delete failed: related articles may exist',
30
+ GITHUB_CODE_REQUIRED: 'GitHub authorization code is required',
31
+ GITHUB_EMAIL_REQUIRED: 'Public email is required for GitHub sign-in',
32
+ EMAIL_NEW_COMMENT: 'New comment notification',
33
+ EMAIL_COMMENT_REPLY: 'Comment reply notification',
34
+ EMAIL_GITHUB_LOGIN: 'GitHub sign-in notification',
35
+ };
36
+ //# sourceMappingURL=api-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-messages.js","sourceRoot":"","sources":["../../src/common/api-messages.ts"],"names":[],"mappings":";;;AACa,QAAA,MAAM,GAAG;IACpB,WAAW,EAAE,uBAAuB;IACpC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,iCAAiC;IACvD,cAAc,EAAE,6BAA6B;IAC7C,iBAAiB,EAAE,sBAAsB;IACzC,qBAAqB,EAAE,iCAAiC;IACxD,iBAAiB,EAAE,mBAAmB;IAEtC,0BAA0B,EAAE,oCAAoC;IAChE,gBAAgB,EAAE,sDAAsD;IACxE,WAAW,EAAE,qBAAqB;IAClC,mBAAmB,EAAE,8BAA8B;IACnD,WAAW,EAAE,mCAAmC;IAChD,SAAS,EAAE,4CAA4C;IACvD,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,WAAW;IAE7B,oBAAoB,EAAE,8BAA8B;IACpD,kBAAkB,EAAE,oBAAoB;IAExC,UAAU,EAAE,oBAAoB;IAChC,eAAe,EAAE,yBAAyB;IAC1C,WAAW,EAAE,qBAAqB;IAClC,gBAAgB,EAAE,+BAA+B;IACjD,yBAAyB,EAAE,2BAA2B;IACtD,mBAAmB,EAAE,2CAA2C;IAEhE,oBAAoB,EAAE,uCAAuC;IAC7D,qBAAqB,EAAE,6CAA6C;IAEpE,iBAAiB,EAAE,0BAA0B;IAC7C,mBAAmB,EAAE,4BAA4B;IACjD,kBAAkB,EAAE,6BAA6B;CACzC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};