@baishuyun/chat-backend 0.0.2 → 0.0.3

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.
@@ -1,25 +1,25 @@
1
- import { type Context, type Next } from "hono";
2
- import { logger } from "./index.js";
3
-
4
- export const logMiddleware = async (c: Context, next: Next) => {
5
- // 记录请求开始时间
6
- const startTime = Date.now();
7
- // 执行后续中间件/路由处理逻辑
8
- await next();
9
- // 计算响应时间
10
- const responseTime = Date.now() - startTime;
11
- // 记录访问日志(info 级别,核心请求信息)
12
- logger.info(
13
- {
14
- method: c.req.method, // 请求方法 GET/POST 等
15
- path: c.req.path, // 请求路径
16
- status: c.res.status, // 响应状态码
17
- responseTime: `${responseTime}ms`, // 响应时间
18
- clientIp:
19
- c.req.header("x-forwarded-for") ||
20
- c.req.header("remote-addr") ||
21
- "unknown", // 客户端 IP
22
- },
23
- "Request processed",
24
- ); // 日志描述信息
25
- };
1
+ import { type Context, type Next } from "hono";
2
+ import { logger } from "./index.js";
3
+
4
+ export const logMiddleware = async (c: Context, next: Next) => {
5
+ // 记录请求开始时间
6
+ const startTime = Date.now();
7
+ // 执行后续中间件/路由处理逻辑
8
+ await next();
9
+ // 计算响应时间
10
+ const responseTime = Date.now() - startTime;
11
+ // 记录访问日志(info 级别,核心请求信息)
12
+ logger.info(
13
+ {
14
+ method: c.req.method, // 请求方法 GET/POST 等
15
+ path: c.req.path, // 请求路径
16
+ status: c.res.status, // 响应状态码
17
+ responseTime: `${responseTime}ms`, // 响应时间
18
+ clientIp:
19
+ c.req.header("x-forwarded-for") ||
20
+ c.req.header("remote-addr") ||
21
+ "unknown", // 客户端 IP
22
+ },
23
+ "Request processed",
24
+ ); // 日志描述信息
25
+ };
@@ -1,23 +1,23 @@
1
- import { Hono } from "hono";
2
- import { fillForm } from "../../controllers/form/fill/fill.controller.js";
3
- import { clearConversation } from "../../controllers/form/conversation/clear.controller.js";
4
- import { buildForm } from "../../controllers/form/build/build.controller.js";
5
- import { uploadAttachment } from "../../controllers/form/attachment-upload.controller.js";
6
-
7
- export const createFormRouter = () => {
8
- const formRouter = new Hono();
9
-
10
- // 智能填数
11
- formRouter.post("/fill", fillForm);
12
-
13
- // 智能搭件
14
- formRouter.post("/build", buildForm);
15
-
16
- // 会话清除
17
- formRouter.post("/conversation/clear", clearConversation);
18
-
19
- // 附件上传
20
- formRouter.post("/attachment/upload", uploadAttachment);
21
-
22
- return formRouter;
23
- };
1
+ import { Hono } from "hono";
2
+ import { fillForm } from "../../controllers/form/fill/fill.controller.js";
3
+ import { clearConversation } from "../../controllers/form/conversation/clear.controller.js";
4
+ import { buildForm } from "../../controllers/form/build/build.controller.js";
5
+ import { uploadAttachment } from "../../controllers/form/attachment-upload.controller.js";
6
+
7
+ export const createFormRouter = () => {
8
+ const formRouter = new Hono();
9
+
10
+ // 智能填数
11
+ formRouter.post("/fill", fillForm);
12
+
13
+ // 智能搭件
14
+ formRouter.post("/build", buildForm);
15
+
16
+ // 会话清除
17
+ formRouter.post("/conversation/clear", clearConversation);
18
+
19
+ // 附件上传
20
+ formRouter.post("/attachment/upload", uploadAttachment);
21
+
22
+ return formRouter;
23
+ };
package/tsconfig.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "extends": "@baishuyun/typescript-config/ts-node.json",
3
- "compilerOptions": {
4
- "jsx": "react-jsx",
5
- "outDir": "./dist",
6
- "jsxImportSource": "hono/jsx"
7
- },
8
- "exclude": ["node_modules", "dist"],
9
- "include": ["config/**/*", "src/**/*"]
10
- }
1
+ {
2
+ "extends": "@baishuyun/typescript-config/ts-node.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "outDir": "./dist",
6
+ "jsxImportSource": "hono/jsx"
7
+ },
8
+ "exclude": ["node_modules", "dist"],
9
+ "include": ["config/**/*", "src/**/*"]
10
+ }