@lark-apaas/fullstack-nestjs-core 1.1.2-alpha.11 → 1.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/dist/index.cjs +2 -4
- package/dist/index.d.cts +2 -14
- package/dist/index.d.ts +2 -14
- package/dist/index.js +2 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,6 @@ __export(index_exports, {
|
|
|
39
39
|
PlatformModule: () => PlatformModule,
|
|
40
40
|
UserContextMiddleware: () => UserContextMiddleware,
|
|
41
41
|
ViewContextMiddleware: () => ViewContextMiddleware,
|
|
42
|
-
apiResponseInterceptor: () => apiResponseInterceptor,
|
|
43
42
|
configureApp: () => configureApp
|
|
44
43
|
});
|
|
45
44
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -265,7 +264,7 @@ CsrfTokenMiddleware = _ts_decorate4([
|
|
|
265
264
|
// src/middlewares/api-fallback/index.ts
|
|
266
265
|
function createApiNotFoundResponse(req) {
|
|
267
266
|
return {
|
|
268
|
-
|
|
267
|
+
code: 404,
|
|
269
268
|
message: `Cannot ${req.method} ${req.path}`,
|
|
270
269
|
error: "Not Found",
|
|
271
270
|
path: req.path,
|
|
@@ -274,7 +273,7 @@ function createApiNotFoundResponse(req) {
|
|
|
274
273
|
}
|
|
275
274
|
__name(createApiNotFoundResponse, "createApiNotFoundResponse");
|
|
276
275
|
function apiResponseInterceptor(req, res, next) {
|
|
277
|
-
if (!req.
|
|
276
|
+
if (!req.baseUrl.startsWith("/api/")) {
|
|
278
277
|
return next();
|
|
279
278
|
}
|
|
280
279
|
res.render = function() {
|
|
@@ -439,7 +438,6 @@ __reExport(index_exports, require("@lark-apaas/nestjs-datapaas"), module.exports
|
|
|
439
438
|
PlatformModule,
|
|
440
439
|
UserContextMiddleware,
|
|
441
440
|
ViewContextMiddleware,
|
|
442
|
-
apiResponseInterceptor,
|
|
443
441
|
configureApp,
|
|
444
442
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
445
443
|
...require("@lark-apaas/nestjs-datapaas")
|
package/dist/index.d.cts
CHANGED
|
@@ -100,23 +100,11 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
100
100
|
* API 404 响应格式
|
|
101
101
|
*/
|
|
102
102
|
interface ApiNotFoundResponse {
|
|
103
|
-
|
|
103
|
+
code: number;
|
|
104
104
|
message: string;
|
|
105
105
|
error: string;
|
|
106
106
|
path: string;
|
|
107
107
|
timestamp: string;
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* API 响应拦截中间件
|
|
111
|
-
*
|
|
112
|
-
* 拦截 ViewModule 的 /* 路由,当其尝试返回 HTML 时
|
|
113
|
-
* 如果请求路径是 /api/*,改为返回 JSON 404
|
|
114
|
-
*
|
|
115
|
-
* 工作原理:
|
|
116
|
-
* 1. 包装 res.render() 和 res.send()
|
|
117
|
-
* 2. render() 直接返回 JSON(肯定是要渲染 HTML)
|
|
118
|
-
* 3. send() 检查 Content-Type 判断是否是 HTML
|
|
119
|
-
*/
|
|
120
|
-
declare function apiResponseInterceptor(req: Request, res: Response, next: NextFunction): void;
|
|
121
109
|
|
|
122
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware,
|
|
110
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -100,23 +100,11 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
100
100
|
* API 404 响应格式
|
|
101
101
|
*/
|
|
102
102
|
interface ApiNotFoundResponse {
|
|
103
|
-
|
|
103
|
+
code: number;
|
|
104
104
|
message: string;
|
|
105
105
|
error: string;
|
|
106
106
|
path: string;
|
|
107
107
|
timestamp: string;
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* API 响应拦截中间件
|
|
111
|
-
*
|
|
112
|
-
* 拦截 ViewModule 的 /* 路由,当其尝试返回 HTML 时
|
|
113
|
-
* 如果请求路径是 /api/*,改为返回 JSON 404
|
|
114
|
-
*
|
|
115
|
-
* 工作原理:
|
|
116
|
-
* 1. 包装 res.render() 和 res.send()
|
|
117
|
-
* 2. render() 直接返回 JSON(肯定是要渲染 HTML)
|
|
118
|
-
* 3. send() 检查 Content-Type 判断是否是 HTML
|
|
119
|
-
*/
|
|
120
|
-
declare function apiResponseInterceptor(req: Request, res: Response, next: NextFunction): void;
|
|
121
109
|
|
|
122
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware,
|
|
110
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
|
package/dist/index.js
CHANGED
|
@@ -222,7 +222,7 @@ CsrfTokenMiddleware = _ts_decorate4([
|
|
|
222
222
|
// src/middlewares/api-fallback/index.ts
|
|
223
223
|
function createApiNotFoundResponse(req) {
|
|
224
224
|
return {
|
|
225
|
-
|
|
225
|
+
code: 404,
|
|
226
226
|
message: `Cannot ${req.method} ${req.path}`,
|
|
227
227
|
error: "Not Found",
|
|
228
228
|
path: req.path,
|
|
@@ -231,7 +231,7 @@ function createApiNotFoundResponse(req) {
|
|
|
231
231
|
}
|
|
232
232
|
__name(createApiNotFoundResponse, "createApiNotFoundResponse");
|
|
233
233
|
function apiResponseInterceptor(req, res, next) {
|
|
234
|
-
if (!req.
|
|
234
|
+
if (!req.baseUrl.startsWith("/api/")) {
|
|
235
235
|
return next();
|
|
236
236
|
}
|
|
237
237
|
res.render = function() {
|
|
@@ -395,6 +395,5 @@ export {
|
|
|
395
395
|
PlatformModule,
|
|
396
396
|
UserContextMiddleware,
|
|
397
397
|
ViewContextMiddleware,
|
|
398
|
-
apiResponseInterceptor,
|
|
399
398
|
configureApp
|
|
400
399
|
};
|