@rongyan/wxpost-server 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -11,18 +11,20 @@
11
11
  ## 安装
12
12
 
13
13
  ```bash
14
- npm install -g @rongyan/wxpost-server
14
+ npm install -g @rongyan/wxpost-server@latest
15
15
  ```
16
16
 
17
- 或直接通过 npx 运行(无需安装):
17
+ ## 初始化配置
18
+
19
+ 首次运行以下命令,程序会自动在 `~/.@rongyan/env.json` 创建配置模板:
18
20
 
19
21
  ```bash
20
- npx @rongyan/wxpost-server
22
+ wxpost-server --help
21
23
  ```
22
24
 
23
- ## 配置
25
+ ![初始化配置](images/init.png)
24
26
 
25
- 首次启动时,程序会自动在 `~/.@rongyan/env.json` 创建配置模板并退出。编辑该文件填入真实值后重启即可。
27
+ 编辑 `~/.@rongyan/env.json`,填入真实值:
26
28
 
27
29
  ```json
28
30
  {
@@ -52,21 +54,26 @@ npx @rongyan/wxpost-server
52
54
  ## 启动
53
55
 
54
56
  ```bash
55
- # 使用配置文件中的端口
57
+ # 直接启动
56
58
  wxpost-server
57
59
 
58
- # 指定端口(优先级最高)
60
+ # 指定端口
59
61
  wxpost-server --port 8080
60
62
 
61
63
  # 通过环境变量指定端口
62
64
  PORT=8080 wxpost-server
63
-
64
- # 开发模式(文件变更自动重启)
65
- npm run dev
66
65
  ```
67
66
 
68
67
  端口优先级:`--port 参数` > `PORT 环境变量` > `配置文件 port` > `默认 3000`
69
68
 
69
+ ### 使用 PM2(推荐生产环境)
70
+
71
+ ```bash
72
+ pm2 start wxpost-server --name wxpost-server -- --port 3000
73
+ pm2 save # 保存进程列表
74
+ pm2 startup # 设置开机自启(按提示执行输出的命令)
75
+ ```
76
+
70
77
  ## IP 白名单
71
78
 
72
79
  微信接口要求服务器 IP 在白名单内。配置路径:
@@ -2,6 +2,22 @@
2
2
 
3
3
  'use strict';
4
4
 
5
+ const args = process.argv.slice(2);
6
+
7
+ if (args.includes('--help') || args.includes('-h')) {
8
+ console.log(`
9
+ Usage: wxpost-server [--port <n>]
10
+
11
+ Options:
12
+ --port <n> 监听端口(优先级高于配置文件和 PORT 环境变量)
13
+ --help, -h 显示帮助
14
+
15
+ 首次运行会自动在 ~/.@rongyan/env.json 创建配置模板。
16
+ 配置文件路径:~/.@rongyan/env.json
17
+ `);
18
+ process.exit(0);
19
+ }
20
+
5
21
  const { startServer } = require('../src/index.js');
6
22
 
7
23
  // 解析 --port <n> 或 --port=<n>
@@ -14,5 +30,5 @@ function parsePort(args) {
14
30
  return null;
15
31
  }
16
32
 
17
- const cliPort = parsePort(process.argv.slice(2));
33
+ const cliPort = parsePort(args);
18
34
  startServer({ port: cliPort });
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rongyan/wxpost-server",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "微信公众号内容发布服务,支持多账号,提供图片上传、草稿管理和发布等 HTTP 接口",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "files": [
10
10
  "bin",
11
11
  "src",
12
+ "images",
12
13
  "README.md"
13
14
  ],
14
15
  "scripts": {