@fastcar/koa 0.1.19 → 0.1.21
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/index.d.ts +14 -0
- package/package.json +29 -17
- package/src/KoaApplication.ts +2 -2
- package/src/annotation/router/AddMapping.ts +14 -10
- package/src/middleware/KoaProxy.ts +29 -0
- package/src/type/KoaConfig.ts +11 -0
- package/target/KoaApplication.js +2 -2
- package/target/annotation/router/AddMapping.js +13 -9
- package/target/middleware/KoaProxy.js +23 -0
- package/test/logs/sys.log +59 -0
- package/test/resource/application.yml +1 -0
package/index.d.ts
CHANGED
|
@@ -38,6 +38,17 @@ export type KoaConfig = {
|
|
|
38
38
|
koaBodyOptions?: { [key: string]: any }; //文件上传的解析
|
|
39
39
|
koaBodyParser?: { [key: string]: any }; //解析请求
|
|
40
40
|
extra?: { [key: string]: any }; //拓展设置
|
|
41
|
+
koaProxy?: {
|
|
42
|
+
//基于http-proxy-middleware来进行拓展
|
|
43
|
+
[key: string]: {
|
|
44
|
+
target: string;
|
|
45
|
+
changeOrigin?: boolean;
|
|
46
|
+
pathRewrite?: {
|
|
47
|
+
[key: string]: string;
|
|
48
|
+
};
|
|
49
|
+
ws: boolean;
|
|
50
|
+
} & any;
|
|
51
|
+
};
|
|
41
52
|
};
|
|
42
53
|
|
|
43
54
|
//全局异常捕捉 可以用自定义的替换这个函数
|
|
@@ -55,6 +66,9 @@ export function KoaCors(app: FastCarApplication): MiddleWareType;
|
|
|
55
66
|
//解析静态文件
|
|
56
67
|
export function KoaStatic(app: FastCarApplication): MiddleWareType;
|
|
57
68
|
|
|
69
|
+
//反向代理文件
|
|
70
|
+
export function KoaProxy(app: FastCarApplication): MiddleWareType;
|
|
71
|
+
|
|
58
72
|
//支持api说明
|
|
59
73
|
export function Swagger(app: FastCarApplication): MiddleWareType;
|
|
60
74
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastcar/koa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"homepage": "https://github.com/williamDazhangyu/fast-car",
|
|
5
5
|
"description": "fastcar框架下对koa的包装",
|
|
6
6
|
"main": "target/index.js",
|
|
@@ -33,30 +33,33 @@
|
|
|
33
33
|
"@fastcar/core": "^0.3.10",
|
|
34
34
|
"@fastcar/server": "^0.0.3",
|
|
35
35
|
"@types/co-body": "^6.1.3",
|
|
36
|
-
"@types/koa": "^
|
|
36
|
+
"@types/koa": "^3.0.1",
|
|
37
37
|
"@types/koa__multer": "*",
|
|
38
|
-
"
|
|
38
|
+
"koa2-cors": "^2.0.6",
|
|
39
39
|
"reflect-metadata": "*"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@koa/bodyparser": "^
|
|
43
|
-
"@koa/router": "^
|
|
44
|
-
"koa": "^
|
|
42
|
+
"@koa/bodyparser": "^6.0.0",
|
|
43
|
+
"@koa/router": "^15.1.1",
|
|
44
|
+
"koa": "^3.1.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@fastcar/core": "*",
|
|
48
48
|
"@fastcar/server": "*",
|
|
49
|
-
"@koa/multer": "
|
|
50
|
-
"@types/koa-mount": "
|
|
51
|
-
"@types/koa-range": "
|
|
52
|
-
"@types/koa-static": "
|
|
53
|
-
"@types/koa2-cors": "
|
|
54
|
-
"
|
|
55
|
-
"koa-
|
|
56
|
-
"koa-
|
|
57
|
-
"koa-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
49
|
+
"@koa/multer": "*",
|
|
50
|
+
"@types/koa-mount": "*",
|
|
51
|
+
"@types/koa-range": "*",
|
|
52
|
+
"@types/koa-static": "*",
|
|
53
|
+
"@types/koa2-cors": "*",
|
|
54
|
+
"http-proxy-middleware": "*",
|
|
55
|
+
"koa-body": "*",
|
|
56
|
+
"koa-mount": "*",
|
|
57
|
+
"koa-range": "*",
|
|
58
|
+
"koa-static": "*",
|
|
59
|
+
"koa2-connect": "*",
|
|
60
|
+
"koa2-cors": "*",
|
|
61
|
+
"multer": "*",
|
|
62
|
+
"path-to-regexp": "*"
|
|
60
63
|
},
|
|
61
64
|
"peerDependenciesMeta": {
|
|
62
65
|
"@types/koa-mount": {
|
|
@@ -103,6 +106,15 @@
|
|
|
103
106
|
},
|
|
104
107
|
"@koa/bodyparser": {
|
|
105
108
|
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"http-proxy-middleware": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"koa2-connect": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"path-to-regexp": {
|
|
117
|
+
"optional": true
|
|
106
118
|
}
|
|
107
119
|
},
|
|
108
120
|
"repository": {
|
package/src/KoaApplication.ts
CHANGED
|
@@ -2,7 +2,7 @@ import "reflect-metadata";
|
|
|
2
2
|
import { ApplicationStart, ApplicationStop, Autowired, Log } from "@fastcar/core/annotation";
|
|
3
3
|
import { FastCarApplication, BootPriority, ComponentKind, Logger } from "@fastcar/core";
|
|
4
4
|
import * as Koa from "koa";
|
|
5
|
-
import
|
|
5
|
+
import KoaRouter from "@koa/router";
|
|
6
6
|
import { MethodType } from "./type/MethodType";
|
|
7
7
|
import { DesignMeta } from "./type/DesignMeta";
|
|
8
8
|
import { TypeUtil, ValidationUtil } from "@fastcar/core/utils";
|
|
@@ -53,7 +53,7 @@ export default class KoaApplication {
|
|
|
53
53
|
*
|
|
54
54
|
*/
|
|
55
55
|
protected loadRoute(): Koa.Middleware {
|
|
56
|
-
|
|
56
|
+
const router = new KoaRouter();
|
|
57
57
|
|
|
58
58
|
let instanceList = this.app.getComponentByType(ComponentKind.Controller);
|
|
59
59
|
|
|
@@ -3,8 +3,7 @@ import { MethodType } from "../../type/MethodType";
|
|
|
3
3
|
import { DesignMeta } from "../../type/DesignMeta";
|
|
4
4
|
|
|
5
5
|
export default function AddMapping(target: any, info: MethodType) {
|
|
6
|
-
|
|
7
|
-
if(!info.url) {
|
|
6
|
+
if (!info.url) {
|
|
8
7
|
info.url = info.method;
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -19,13 +18,18 @@ export default function AddMapping(target: any, info: MethodType) {
|
|
|
19
18
|
Reflect.defineMetadata(DesignMeta.ROUTER_MAP, routerMap, target);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
//修改主键 根据url-method作为唯一主键
|
|
22
|
+
info.request.forEach((m) => {
|
|
23
|
+
let urlKey = `${info.url}:${m}`;
|
|
24
|
+
|
|
25
|
+
let curr = routerMap.get(urlKey);
|
|
26
|
+
if (!curr) {
|
|
27
|
+
routerMap.set(urlKey, info);
|
|
28
|
+
} else {
|
|
29
|
+
if (info.url != curr.url) {
|
|
30
|
+
console.warn(`The two URL names are inconsisten in (${info.url},${curr.url})`);
|
|
31
|
+
}
|
|
32
|
+
curr.request = [...info.request, ...curr.request];
|
|
28
33
|
}
|
|
29
|
-
|
|
30
|
-
}
|
|
34
|
+
});
|
|
31
35
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FastCarApplication } from "@fastcar/core";
|
|
2
|
+
import * as Koa from "koa";
|
|
3
|
+
import { KoaConfig } from "../type/KoaConfig";
|
|
4
|
+
|
|
5
|
+
//反向代理扩展
|
|
6
|
+
export default function KoaProxy(app: FastCarApplication): Koa.Middleware {
|
|
7
|
+
const httpProxy = require("http-proxy-middleware");
|
|
8
|
+
const k2c = require("koa2-connect");
|
|
9
|
+
const { match } = require("path-to-regexp");
|
|
10
|
+
|
|
11
|
+
return async function (ctx, next) {
|
|
12
|
+
let koaConfig: KoaConfig = app.getSetting("koa");
|
|
13
|
+
|
|
14
|
+
if (koaConfig && koaConfig.koaProxy) {
|
|
15
|
+
const { path } = ctx;
|
|
16
|
+
for (const route of Object.keys(koaConfig.koaProxy)) {
|
|
17
|
+
if (
|
|
18
|
+
match(route, {
|
|
19
|
+
decode: decodeURIComponent,
|
|
20
|
+
})(path)
|
|
21
|
+
) {
|
|
22
|
+
return await k2c(httpProxy.createProxyMiddleware(koaConfig.koaProxy[route]))(ctx, next);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await next();
|
|
28
|
+
};
|
|
29
|
+
}
|
package/src/type/KoaConfig.ts
CHANGED
|
@@ -7,4 +7,15 @@ export type KoaConfig = {
|
|
|
7
7
|
koaBodyOptions?: { [key: string]: any }; //文件上传的解析
|
|
8
8
|
koaBodyParser?: { [key: string]: any }; //bodyParser.Options; //解析请求
|
|
9
9
|
extra?: { [key: string]: any }; //拓展设置
|
|
10
|
+
koaProxy?: {
|
|
11
|
+
//基于http-proxy-middleware来进行拓展
|
|
12
|
+
[key: string]: {
|
|
13
|
+
target: string;
|
|
14
|
+
changeOrigin?: boolean;
|
|
15
|
+
pathRewrite?: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
ws: boolean;
|
|
19
|
+
} & any;
|
|
20
|
+
};
|
|
10
21
|
};
|
package/target/KoaApplication.js
CHANGED
|
@@ -13,7 +13,7 @@ require("reflect-metadata");
|
|
|
13
13
|
const annotation_1 = require("@fastcar/core/annotation");
|
|
14
14
|
const core_1 = require("@fastcar/core");
|
|
15
15
|
const Koa = require("koa");
|
|
16
|
-
const
|
|
16
|
+
const router_1 = require("@koa/router");
|
|
17
17
|
const DesignMeta_1 = require("./type/DesignMeta");
|
|
18
18
|
const utils_1 = require("@fastcar/core/utils");
|
|
19
19
|
const server_1 = require("@fastcar/server");
|
|
@@ -52,7 +52,7 @@ let KoaApplication = class KoaApplication {
|
|
|
52
52
|
*
|
|
53
53
|
*/
|
|
54
54
|
loadRoute() {
|
|
55
|
-
|
|
55
|
+
const router = new router_1.default();
|
|
56
56
|
let instanceList = this.app.getComponentByType(core_1.ComponentKind.Controller);
|
|
57
57
|
//查找绑定的url
|
|
58
58
|
instanceList.forEach((instance) => {
|
|
@@ -16,14 +16,18 @@ function AddMapping(target, info) {
|
|
|
16
16
|
routerMap = new Map();
|
|
17
17
|
Reflect.defineMetadata(DesignMeta_1.DesignMeta.ROUTER_MAP, routerMap, target);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
console.warn(`The two URL names are inconsisten in (${info.url},${curr.url})`);
|
|
19
|
+
//修改主键 根据url-method作为唯一主键
|
|
20
|
+
info.request.forEach((m) => {
|
|
21
|
+
let urlKey = `${info.url}:${m}`;
|
|
22
|
+
let curr = routerMap.get(urlKey);
|
|
23
|
+
if (!curr) {
|
|
24
|
+
routerMap.set(urlKey, info);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
else {
|
|
27
|
+
if (info.url != curr.url) {
|
|
28
|
+
console.warn(`The two URL names are inconsisten in (${info.url},${curr.url})`);
|
|
29
|
+
}
|
|
30
|
+
curr.request = [...info.request, ...curr.request];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
29
33
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = KoaProxy;
|
|
4
|
+
//反向代理扩展
|
|
5
|
+
function KoaProxy(app) {
|
|
6
|
+
const httpProxy = require("http-proxy-middleware");
|
|
7
|
+
const k2c = require("koa2-connect");
|
|
8
|
+
const { match } = require("path-to-regexp");
|
|
9
|
+
return async function (ctx, next) {
|
|
10
|
+
let koaConfig = app.getSetting("koa");
|
|
11
|
+
if (koaConfig && koaConfig.koaProxy) {
|
|
12
|
+
const { path } = ctx;
|
|
13
|
+
for (const route of Object.keys(koaConfig.koaProxy)) {
|
|
14
|
+
if (match(route, {
|
|
15
|
+
decode: decodeURIComponent,
|
|
16
|
+
})(path)) {
|
|
17
|
+
return await k2c(httpProxy.createProxyMiddleware(koaConfig.koaProxy[route]))(ctx, next);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
await next();
|
|
22
|
+
};
|
|
23
|
+
}
|
package/test/logs/sys.log
CHANGED
|
@@ -147,3 +147,62 @@
|
|
|
147
147
|
{"timestamp":"2025-07-29 16:31:11.648","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
148
148
|
{"timestamp":"2025-07-29 16:31:11.648","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
149
149
|
{"timestamp":"2025-07-29 16:31:11.649","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
150
|
+
{"timestamp":"2025-12-22 17:28:39.115","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
151
|
+
{"timestamp":"2025-12-22 17:28:41.189","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
152
|
+
{"timestamp":"2025-12-22 17:28:41.190","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
153
|
+
{"timestamp":"2025-12-22 17:28:43.337","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
154
|
+
{"timestamp":"2025-12-22 17:28:43.338","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
155
|
+
{"timestamp":"2025-12-22 17:28:43.339","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
156
|
+
{"timestamp":"2025-12-22 17:31:22.709","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
157
|
+
{"timestamp":"2025-12-22 17:31:23.51","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
158
|
+
{"timestamp":"2025-12-22 17:31:23.52","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
159
|
+
{"timestamp":"2025-12-22 17:31:23.100","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
160
|
+
{"timestamp":"2025-12-22 17:31:23.101","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
161
|
+
{"timestamp":"2025-12-22 17:31:23.101","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
162
|
+
{"timestamp":"2025-12-22 17:32:19.934","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
163
|
+
{"timestamp":"2025-12-22 17:32:20.252","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
164
|
+
{"timestamp":"2025-12-22 17:32:20.253","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
165
|
+
{"timestamp":"2025-12-22 17:32:20.303","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
166
|
+
{"timestamp":"2025-12-22 17:32:20.304","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
167
|
+
{"timestamp":"2025-12-22 17:32:20.305","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
168
|
+
{"timestamp":"2025-12-23 10:47:56.901","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
169
|
+
{"timestamp":"2025-12-23 10:47:59.717","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
170
|
+
{"timestamp":"2025-12-23 10:47:59.718","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
171
|
+
{"timestamp":"2025-12-23 10:47:59.730","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
172
|
+
{"timestamp":"2025-12-23 10:47:59.731","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
173
|
+
{"timestamp":"2025-12-23 10:47:59.731","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
174
|
+
{"timestamp":"2025-12-23 10:49:47.715","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
175
|
+
{"timestamp":"2025-12-23 10:49:48.98","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
176
|
+
{"timestamp":"2025-12-23 10:49:48.99","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
177
|
+
{"timestamp":"2025-12-23 10:49:48.106","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
178
|
+
{"timestamp":"2025-12-23 10:49:48.106","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
179
|
+
{"timestamp":"2025-12-23 10:49:48.107","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
180
|
+
{"timestamp":"2025-12-23 10:59:33.290","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
181
|
+
{"timestamp":"2025-12-23 10:59:33.820","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
182
|
+
{"timestamp":"2025-12-23 10:59:33.822","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
183
|
+
{"timestamp":"2025-12-23 10:59:33.833","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
184
|
+
{"timestamp":"2025-12-23 10:59:33.834","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
185
|
+
{"timestamp":"2025-12-23 10:59:33.835","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
186
|
+
{"timestamp":"2025-12-23 22:14:30.131","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
187
|
+
{"timestamp":"2025-12-23 22:14:33.982","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
188
|
+
{"timestamp":"2025-12-23 22:14:33.984","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
189
|
+
{"timestamp":"2025-12-23 22:14:34.06","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
190
|
+
{"timestamp":"2025-12-23 22:14:34.07","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
191
|
+
{"timestamp":"2025-12-23 22:14:34.09","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
192
|
+
{"timestamp":"2025-12-23 22:29:19.999","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
193
|
+
{"timestamp":"2025-12-23 22:29:20.679","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
194
|
+
{"timestamp":"2025-12-23 22:29:20.681","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
195
|
+
{"timestamp":"2025-12-23 22:29:20.692","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
196
|
+
{"timestamp":"2025-12-23 22:29:20.693","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
197
|
+
{"timestamp":"2025-12-23 22:29:20.694","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
198
|
+
{"timestamp":"2025-12-24 16:51:54.144","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
199
|
+
{"timestamp":"2025-12-24 16:51:55.401","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
200
|
+
{"timestamp":"2025-12-24 16:51:55.401","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
201
|
+
{"timestamp":"2025-12-24 16:51:55.404","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
202
|
+
{"timestamp":"2025-12-24 16:51:55.408","level":"ERROR","label":"sys","message":"reason: Cannot find module 'koa2-cors'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaCors.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaCors.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module 'koa2-cors'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaCors.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.<anonymous> (node:internal/modules/cjs/loader:1401:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)\n at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)\n at Function._load (node:internal/modules/cjs/loader:1211:37)\n at TracingChannel.traceSync (node:diagnostics_channel:322:14)\n at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)\n at Module.require (node:internal/modules/cjs/loader:1487:12)\n at require (node:internal/modules/helpers:135:16)\n at KoaApplication.KoaCors (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaCors.ts:6:19)"}
|
|
203
|
+
{"timestamp":"2025-12-24 16:52:22.882","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
204
|
+
{"timestamp":"2025-12-24 16:52:23.412","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
205
|
+
{"timestamp":"2025-12-24 16:52:23.413","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
206
|
+
{"timestamp":"2025-12-24 16:52:49.516","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
207
|
+
{"timestamp":"2025-12-24 16:52:49.517","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
208
|
+
{"timestamp":"2025-12-24 16:52:49.518","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
@@ -8,6 +8,7 @@ settings:
|
|
|
8
8
|
swagger:
|
|
9
9
|
enable: true
|
|
10
10
|
api: { "index": "/public/api/index.yaml" }
|
|
11
|
+
koaProxy: { "/:path(.*).php": { target: "http://localhost.better.lg", changeOrigin: true }, "/api/:path*": { target: "https://localhost.better.lg", "changeOrigin": true } }
|
|
11
12
|
extra: #额外配置支持
|
|
12
13
|
cors: #跨域支持示范
|
|
13
14
|
origin: "https://localhost:1234"
|