当前位置:网站首页>Nodejs defines token Middleware
Nodejs defines token Middleware
2022-07-20 11:48:00 【Your beauty fascinates me】
// Be sure to before routing , Configuration analysis token Middleware
const expressJWT=require('express-jwt')
const config=require('./common/config')
app.use(expressJWT({
secret:config.jwtScretKey}).unless({
path:[/^\/api/]}))
// Define error level file
if(err.name=='UnauthorizedError') return res.cc(' Authentication failed !')
app.use((err,req,res,next)=>{
// Error caused by validation failure
if(err instanceof joi.ValidationError) return res.cc(err)
// Error of identity authentication failure
if(err.name=='UnauthorizedError') return res.cc(' Authentication failed !')
// Unknown error
res.cc(err)
})
边栏推荐
- 旋转数组 189, 153, 154, 33, 81, 10.03
- leetcode-11 盛水最多的容器(双指针,lower_bound, upperbound)
- 文件、异常、模块
- Rsync了解
- OSError: exception: access violation writing 0x0000000000000000
- 为什么把 360bookmarks拷到新电脑上无法恢复收藏夹,因为 他是加密的 您可以使用360sefav_日期.favdb和360default_ori_日期.favdb两种收藏夹备份文件导入浏览器
- MySQL学习笔记——视图
- 流量控制系统pid整定方法仿真
- 中文同义句在线转换器 - 中文同义句转换器软件
- 2022 electrician (elementary) operation certificate examination questions and answers
猜你喜欢
Processing of paging data
软件开发设计流程
20220710 leetcode周赛:移动片段得到字符串
Basic knowledge points of reptiles (1)
Simulation of PID tuning method in flow control system
Resolved (selenium reports an error) attributeerror: 'webdriver' object has no attribute 'execute_ cdp_ cmd‘
Design and software implementation of FIR digital filter in Digital Signal Processing Experiment III
【NightCafe AI】一分钟创建你想要的NFT数字艺术藏品
Digital signal processing experiment I system response and system stability
ERP capability planning and scheduling
随机推荐
IPv6-ICMPv6协议
【异常】异常解决文章格式
gin注册自定義中間件失效
Basic knowledge points of reptiles (1)
不同的ip执行相同的sql脚本会出错吗
Méthode d'évaluation des erreurs de cylindricité basée sur MATLAB
结合GUI和simulink的三相电路谐波的检测与建模
将Float类型的数字保留2位小数
Towhee daily model weekly report
The El input input box needs to support multiple inputs
MySQL optimization to be improved
MySQL调优待完善
Error analysis of yyyy-mm-dd
2022 Shandong Province safety officer C certificate operation certificate examination questions and answers
Big programmers' daily work | daily anecdotes
项目中的基础知识
Design and Simulation of infinite impulse response digital filter based on MATLAB
Wechat applet bindinput and click the button to assign the content of the current text
Harmonic detection and modeling of three-phase circuit based on GUI and Simulink
JSON. Parse error when parse occurs \n