feat: 标准响应函数

This commit is contained in:
luozhj33 2026-03-19 01:25:45 +08:00
parent 9ccd1c7d88
commit ca0c07857e

View File

@ -0,0 +1,21 @@
const responseCodes = {
200: '请求成功',
400: '请求参数错误',
401: '未授权,请先登录',
403: '没有访问权限',
404: '请求的资源不存在',
500: '服务器内部错误'
};
// 标准响应
function standardResponse(code, message, data) {
return {
code: code,
message: message ?? responseCodes[code],
data: data
};
}
module.exports = {
standardResponse
};