@lark-apaas/fullstack-nestjs-core 1.1.2-alpha.10 → 1.1.2-alpha.11
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/dist/index.cjs +49 -28479
- package/dist/index.d.cts +18 -14
- package/dist/index.d.ts +18 -14
- package/dist/index.js +23 -28480
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -97,22 +97,26 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* API 404
|
|
100
|
+
* API 404 响应格式
|
|
101
|
+
*/
|
|
102
|
+
interface ApiNotFoundResponse {
|
|
103
|
+
statusCode: number;
|
|
104
|
+
message: string;
|
|
105
|
+
error: string;
|
|
106
|
+
path: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* API 响应拦截中间件
|
|
101
111
|
*
|
|
102
|
-
*
|
|
112
|
+
* 拦截 ViewModule 的 /* 路由,当其尝试返回 HTML 时
|
|
113
|
+
* 如果请求路径是 /api/*,改为返回 JSON 404
|
|
103
114
|
*
|
|
104
115
|
* 工作原理:
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* 3. 通配符 (/api/*) - 本 Controller
|
|
109
|
-
* 4. 更宽泛的通配符 (/*) - ViewModule
|
|
110
|
-
*
|
|
111
|
-
* 因此即使 PlatformModule 在其他业务模块之前导入,
|
|
112
|
-
* 具体的 API 路由仍然会优先匹配,不会被拦截。
|
|
116
|
+
* 1. 包装 res.render() 和 res.send()
|
|
117
|
+
* 2. render() 直接返回 JSON(肯定是要渲染 HTML)
|
|
118
|
+
* 3. send() 检查 Content-Type 判断是否是 HTML
|
|
113
119
|
*/
|
|
114
|
-
declare
|
|
115
|
-
handleNotFound(req: Request, res: Response): Response<any, Record<string, any>>;
|
|
116
|
-
}
|
|
120
|
+
declare function apiResponseInterceptor(req: Request, res: Response, next: NextFunction): void;
|
|
117
121
|
|
|
118
|
-
export {
|
|
122
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, apiResponseInterceptor, configureApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -97,22 +97,26 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* API 404
|
|
100
|
+
* API 404 响应格式
|
|
101
|
+
*/
|
|
102
|
+
interface ApiNotFoundResponse {
|
|
103
|
+
statusCode: number;
|
|
104
|
+
message: string;
|
|
105
|
+
error: string;
|
|
106
|
+
path: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* API 响应拦截中间件
|
|
101
111
|
*
|
|
102
|
-
*
|
|
112
|
+
* 拦截 ViewModule 的 /* 路由,当其尝试返回 HTML 时
|
|
113
|
+
* 如果请求路径是 /api/*,改为返回 JSON 404
|
|
103
114
|
*
|
|
104
115
|
* 工作原理:
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* 3. 通配符 (/api/*) - 本 Controller
|
|
109
|
-
* 4. 更宽泛的通配符 (/*) - ViewModule
|
|
110
|
-
*
|
|
111
|
-
* 因此即使 PlatformModule 在其他业务模块之前导入,
|
|
112
|
-
* 具体的 API 路由仍然会优先匹配,不会被拦截。
|
|
116
|
+
* 1. 包装 res.render() 和 res.send()
|
|
117
|
+
* 2. render() 直接返回 JSON(肯定是要渲染 HTML)
|
|
118
|
+
* 3. send() 检查 Content-Type 判断是否是 HTML
|
|
113
119
|
*/
|
|
114
|
-
declare
|
|
115
|
-
handleNotFound(req: Request, res: Response): Response<any, Record<string, any>>;
|
|
116
|
-
}
|
|
120
|
+
declare function apiResponseInterceptor(req: Request, res: Response, next: NextFunction): void;
|
|
117
121
|
|
|
118
|
-
export {
|
|
122
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, apiResponseInterceptor, configureApp };
|