Gathering detailed insights and metrics for pwegg
Gathering detailed insights and metrics for pwegg
Gathering detailed insights and metrics for pwegg
Gathering detailed insights and metrics for pwegg
npm install pwegg
Typescript
Module System
Node Version
NPM Version
47.2
Supply Chain
89.3
Quality
74.9
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
5
Compared to previous week
Last month
500%
6
Compared to previous month
Last year
-14.9%
57
Compared to previous year
No dependencies detected.
在config/plugin.js 开启插件
'egg-mysql':{
enable: true,
package:'egg-mysql'
},
'egg-cors':{ enable:true, package:'egg-cors' },
在config/config.delault.js 注册插件
'cors':{//后端跨域 origin:'*', allowMethods:'GET,PUT,POST,DELETE' }
password=${password}&secret=hss
return md5(str)
}
module.exports=getPasswordtoken
axios 拦截 挂载 token config.headers.authorization=Cookie.get('token')
封装鉴权 app/middleware/auth.js
'use strict';
const jwt = require('jsonwebtoken');
module.exports = () => {
return async function auth(ctx, next) {
// 获取前端传来的token
const { authorization } = ctx.request.headers;
// 获取token
const token = authorization.split(' ')[1];
try {
// 尝试运行 try函数
jwt.verify(token, '1902A');
await next();
} catch (error) {
// 如果try函数监听到运行失败 运行catch
console.log('解密失败');
ctx.body = {
code: 0,
msg: '请重修登录',
};
}
};
};
eg:
const { router, controller, middleware } = app;
// 获取用户信息
router.post('/api/userinfo', middleware.auth(), controller.login.getUserInfo);
No vulnerabilities found.
No security vulnerabilities found.