@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
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
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
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const { spawn, spawnSync } = require('child_process');
|
|
12
|
+
|
|
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();
|
|
17
|
+
|
|
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');
|
|
22
|
+
|
|
23
|
+
// Show help if requested
|
|
24
|
+
if (showHelp) {
|
|
25
|
+
console.log(`
|
|
26
|
+
ReactPress Server - NestJS-based backend API for ReactPress CMS
|
|
27
|
+
|
|
28
|
+
Usage:
|
|
29
|
+
reactpress-server [options]
|
|
30
|
+
(éå¸¸įą reactpress-cli start č°į¨)
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
--pm2 Start server with PM2 process manager
|
|
34
|
+
--help, -h Show this help message
|
|
35
|
+
|
|
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
|
+
}
|
|
42
|
+
|
|
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
|
|
56
|
+
try {
|
|
57
|
+
spawnSync('pm2', ['--version'], { stdio: 'ignore' });
|
|
58
|
+
return true;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return false;
|
|
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
|
|
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
|
+
}
|
|
80
|
+
|
|
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');
|
|
88
|
+
process.exit(1);
|
|
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
|
+
});
|
|
101
|
+
|
|
102
|
+
if (buildResult.status !== 0) {
|
|
103
|
+
console.error('[ReactPress Server] Failed to build server');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
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';
|
|
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
|
+
});
|
|
128
|
+
|
|
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'], {
|
|
141
|
+
stdio: 'inherit',
|
|
142
|
+
cwd: serverDir
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
pm2.on('close', (code) => {
|
|
146
|
+
console.log(`[ReactPress Server] PM2 process exited with code ${code}`);
|
|
147
|
+
process.exit(code);
|
|
148
|
+
});
|
|
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
|
+
}
|
|
197
|
+
|
|
198
|
+
// Main execution
|
|
199
|
+
if (usePM2) {
|
|
200
|
+
startWithPM2();
|
|
201
|
+
} else {
|
|
202
|
+
startWithNode();
|
|
203
|
+
}
|
package/dist/app.module.js
CHANGED
|
@@ -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
|
|
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: [
|
|
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: [
|
|
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: [],
|
package/dist/app.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AACA,2DAAyD;AACzD,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;AACxD,qEAA0D;AAC1D,qEAAgE;AAChE,uFAA4E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a;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 {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@nestjs/core");
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const app_module_1 = require("./app.module");
|
|
8
|
+
async function generateSwaggerJson() {
|
|
9
|
+
let app;
|
|
10
|
+
try {
|
|
11
|
+
console.log('đ Starting Swagger JSON generation...');
|
|
12
|
+
app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule, {
|
|
13
|
+
logger: ['error', 'warn'],
|
|
14
|
+
});
|
|
15
|
+
const configService = app.get('ConfigService');
|
|
16
|
+
const apiPrefix = configService.get('SERVER_API_PREFIX', '/api');
|
|
17
|
+
console.log('đ Configuring Swagger documentation...');
|
|
18
|
+
const swaggerConfig = new swagger_1.DocumentBuilder()
|
|
19
|
+
.setTitle('ReactPress API Documentation')
|
|
20
|
+
.setDescription('Comprehensive API documentation for ReactPress - A modern content management system built with NestJS')
|
|
21
|
+
.setVersion('2.0')
|
|
22
|
+
.setContact('ReactPress Team', 'https://github.com/fecommunity/reactpress', 'admin@gaoredu.com')
|
|
23
|
+
.setLicense('MIT', 'https://github.com/fecommunity/reactpress/blob/main/LICENSE')
|
|
24
|
+
.addServer(configService.get('SERVER_SITE_URL', 'http://localhost:3002'), 'API Server')
|
|
25
|
+
.build();
|
|
26
|
+
console.log('đ¨ Generating Swagger document...');
|
|
27
|
+
const document = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
|
|
28
|
+
const outputPath = path_1.join(__dirname, '../public/swagger.json');
|
|
29
|
+
const publicDir = path_1.join(__dirname, '../public');
|
|
30
|
+
if (!fs_1.existsSync(publicDir)) {
|
|
31
|
+
console.log('đ Creating public directory...');
|
|
32
|
+
require('fs').mkdirSync(publicDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
if (fs_1.existsSync(outputPath)) {
|
|
35
|
+
console.log('đī¸ Removing existing swagger.json file...');
|
|
36
|
+
fs_1.unlinkSync(outputPath);
|
|
37
|
+
}
|
|
38
|
+
console.log('đž Writing Swagger JSON to file...');
|
|
39
|
+
fs_1.writeFileSync(outputPath, JSON.stringify(document, null, 2));
|
|
40
|
+
console.log(`â
Success! Swagger JSON generated at: ${outputPath}`);
|
|
41
|
+
console.log('đ Swagger generation process completed successfully');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('â Error during Swagger generation:', error.message);
|
|
46
|
+
const existingPath = path_1.join(__dirname, '../public/swagger.json');
|
|
47
|
+
if (fs_1.existsSync(existingPath)) {
|
|
48
|
+
console.log('âšī¸ Using existing swagger.json file');
|
|
49
|
+
console.log('đ Swagger generation process completed successfully');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.error('â No existing swagger.json file found');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
generateSwaggerJson().catch(e => {
|
|
61
|
+
console.error('đĨ Unhandled error in generateSwaggerJson:', e.message);
|
|
62
|
+
const existingPath = path_1.join(__dirname, '../public/swagger.json');
|
|
63
|
+
if (fs_1.existsSync(existingPath)) {
|
|
64
|
+
console.log('âšī¸ Using existing swagger.json file');
|
|
65
|
+
console.log('đ Swagger generation process completed successfully');
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.error('â No existing swagger.json file found');
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=generate-swagger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-swagger.js","sourceRoot":"","sources":["../src/generate-swagger.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAiE;AACjE,2BAA2D;AAC3D,+BAA4B;AAC5B,6CAAyC;AAEzC,KAAK,UAAU,mBAAmB;IAChC,IAAI,GAAG,CAAC;IACR,IAAI;QACF,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QAGtD,GAAG,GAAG,MAAM,kBAAW,CAAC,wBAAwB,CAAC,sBAAS,EAAE;YAC1D,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;SAC1B,CAAC,CAAC;QAGH,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;QAEjE,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QAGvD,MAAM,aAAa,GAAG,IAAI,yBAAe,EAAE;aACxC,QAAQ,CAAC,8BAA8B,CAAC;aACxC,cAAc,CAAC,uGAAuG,CAAC;aACvH,UAAU,CAAC,KAAK,CAAC;aACjB,UAAU,CAAC,iBAAiB,EAAE,2CAA2C,EAAE,mBAAmB,CAAC;aAC/F,UAAU,CAAC,KAAK,EAAE,6DAA6D,CAAC;aAChF,SAAS,CAAC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