修复endpoints构建router时参数传错

This commit is contained in:
Wang Kejun 2023-10-20 17:36:05 +08:00
parent 6bf15a68b8
commit 7fa8782323
2 changed files with 7 additions and 6 deletions

View File

@ -116,9 +116,9 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
}
});
// 注入所有的endpoints
const endpoints = appLoader.getEndpoints();
const endpoints = appLoader.getEndpoints(connector.getEndpointRouter());
endpoints.forEach(([name, method, url, fn]) => {
router[method](name, url, async (ctx) => {
router[method](url, async (ctx) => {
const { req, request, params } = ctx;
const { body, headers } = request;
try {
@ -132,7 +132,7 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
}
});
});
router.get('/endpoint', async (ctx) => {
router.get(connector.getEndpointRouter(), async (ctx) => {
ctx.response.body = endpoints;
});
koa.use(router.routes());

View File

@ -132,10 +132,10 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
});
// 注入所有的endpoints
const endpoints = appLoader.getEndpoints();
const endpoints = appLoader.getEndpoints(connector.getEndpointRouter());
endpoints.forEach(
([name, method, url, fn]) => {
router[method](name, url, async (ctx) => {
router[method](url, async (ctx) => {
const { req, request, params } = ctx;
const { body, headers } = request;
try {
@ -150,7 +150,8 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
});
}
);
router.get('/endpoint', async (ctx) => {
router.get(connector.getEndpointRouter(), async (ctx) => {
ctx.response.body = endpoints;
});