1.0.1 • Published 2 years ago

itmao-rescc v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install itmao-rescc

导入中间件

const itmaoRescc = require("itmao-rescc");

app 注册使用中间件

//这是响应错误信息的中间件
app.use(itmaoRescc);
//注:在路由之前使用

在路由里面就可以使用 res.cc 函数处理错误信息

//参数为一个错误对象
res.cc(err);
//参数为一个错误的描述字符串
res.cc("用户名被占用,请更换其它用户名");
//参数为一个字符串,和一个状态信息status,默认情况status为1
res.cc("注册成功!", 0);

开源协议

ISC