我是 Typescript 的新手,正在尝试集成koa-router
和koa-passport
. 全部安装@types\
import Koa from "koa";
import Route from "koa-router";
import passport from "koa-passport";
import session from "koa-session";
const app = new Koa();
const router = new Route();
app.keys = [process.env.SECRET_KEY || "secret"];
app.use(session({}, app));
app.use(passport.initialize());
app.use(passport.session());
app.use(router.routes()).use(router.allowedMethods());
当我尝试passport
使用router
.
router.post("Logout", "/logout", ctx => {
if (ctx.isAuthenticated()) {
ctx.logout();
}
});
上下文(ctx)方法有错误
Property 'isAuthenticated' does not exist on type 'ParameterizedContext<any, IRouterParamContext<any, {}>>'.
Property 'logout' does not exist on type 'ParameterizedContext<any, IRouterParamContext<any, {}>>'.
我尝试了不同的方法,但没有成功。感谢任何帮助。