@stylewx/api 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +47 -0
  2. package/package.json +25 -4
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @stylewx/api
2
+
3
+ 把 [MCP 工具](https://www.npmjs.com/package/@stylewx/mcp-server) 的能力镜像成 REST API,
4
+ 基于 [Hono](https://hono.dev),可跑在 Node 或任意支持 `fetch` 的运行时。
5
+
6
+ ## 安装与启动
7
+
8
+ ```bash
9
+ npm i @stylewx/api
10
+
11
+ # 该包未声明 bin,直接起编译产物即可
12
+ PORT=3000 node node_modules/@stylewx/api/dist/index.js
13
+ ```
14
+
15
+ ## 端点
16
+
17
+ | 方法 | 路径 | 说明 |
18
+ | --- | --- | --- |
19
+ | `GET` | `/health` | 健康检查 |
20
+ | `GET` | `/themes` | 主题清单(含本地已保存主题) |
21
+ | `POST` | `/themes/generate` | 按文章内容用 LLM 生成主题 |
22
+ | `POST` | `/render` | Markdown + 主题 → 微信可用 HTML |
23
+ | `POST` | `/validate` | 校验 HTML 是否符合微信约束 |
24
+ | `POST` | `/drafts` | 渲染并发布到公众号草稿箱(只发草稿) |
25
+
26
+ ```bash
27
+ curl -s localhost:3000/render \
28
+ -H 'content-type: application/json' \
29
+ -d '{"markdown":"# 标题\n\n正文","theme":"magazine"}'
30
+ ```
31
+
32
+ ## 作为库使用
33
+
34
+ ```ts
35
+ import { createApp } from '@stylewx/api'
36
+
37
+ export default createApp() // 挂到任意支持的运行时
38
+ ```
39
+
40
+ ## 凭据
41
+
42
+ 发布到草稿箱需要 `WECHAT_APP_ID` / `WECHAT_APP_SECRET`;
43
+ 生成主题需要 `LLM_BASE_URL` / `LLM_API_KEY` / `LLM_MODEL`(见主仓库 `.env.example`)。
44
+
45
+ ---
46
+
47
+ 属于 **[stylewx](https://github.com/wjunhere/stylewx)** —— 把 Markdown 排成微信公众号文章的工具链。MIT License.
package/package.json CHANGED
@@ -1,7 +1,25 @@
1
1
  {
2
2
  "name": "@stylewx/api",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "stylewx REST API: mirrors the MCP tools as HTTP endpoints, reusing the same service layer.",
5
+ "keywords": [
6
+ "wechat",
7
+ "wechat-article",
8
+ "rest-api",
9
+ "hono",
10
+ "markdown"
11
+ ],
12
+ "license": "MIT",
13
+ "author": {
14
+ "name": "wjunhere",
15
+ "url": "https://github.com/wjunhere"
16
+ },
17
+ "homepage": "https://github.com/wjunhere/stylewx#readme",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/wjunhere/stylewx.git",
21
+ "directory": "apps/api"
22
+ },
5
23
  "type": "module",
6
24
  "main": "./dist/index.js",
7
25
  "types": "./dist/index.d.ts",
@@ -18,13 +36,16 @@
18
36
  "@hono/node-server": "^1.13.0",
19
37
  "hono": "^4.6.0",
20
38
  "zod": "^4.0.0",
21
- "@stylewx/publisher": "0.2.0",
22
- "@stylewx/service": "0.2.0",
23
- "@stylewx/theme": "0.2.0"
39
+ "@stylewx/publisher": "0.2.2",
40
+ "@stylewx/service": "0.2.2",
41
+ "@stylewx/theme": "0.2.2"
24
42
  },
25
43
  "publishConfig": {
26
44
  "access": "public"
27
45
  },
46
+ "engines": {
47
+ "node": ">=20"
48
+ },
28
49
  "scripts": {
29
50
  "build": "tsc -p tsconfig.json",
30
51
  "test": "vitest run",