这是我创建的一个小型中间件,用于在我的 nodejs 应用程序测试期间跳过身份验证:
authentication(auth) {
if (process.env.NODE_ENV !== 'test') {
return jwt({
secret: new Buffer(auth.secret, 'base64'),
audience: auth.clientId
});
} else {
return (req, res, next) => { next(); };
}
}
我对它的外观不满意。有没有更优雅的方式来实现这一点?