expressServer/common/constant/httpStatus.js
LingandRX 7ea50c9d52 refactor(env and controllers): 优化环境变量配置和用户控制器逻辑
- 添加 NODE_ENV 环境变量以指定开发环境
- 重构 httpStatus.js 文件的模块导出方式
- 修正用户控制器中的错误处理和消息返回
- 统一使用 messages 对象替代 successMessages
- 增加登录功能中的错误日志记录
2024-12-30 22:21:29 +08:00

71 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* HTTP 状态码常量
*/
const HTTP_STATUS = {
// 信息响应 (100199)
/** @type {number} 继续 */
CONTINUE: 100,
/** @type {number} 协议切换 */
SWITCHING_PROTOCOLS: 101,
// 成功响应 (200299)
/** @type {number} 请求成功 */
OK: 200,
/** @type {number} 请求成功并且服务器创建了新的资源 */
CREATED: 201,
/** @type {number} 已接受 */
ACCEPTED: 202,
/** @type {number} 没有内容 */
NO_CONTENT: 204,
// 重定向消息 (300399)
/** @type {number} 永久移动 */
MOVED_PERMANENTLY: 301,
/** @type {number} 找到 */
FOUND: 302,
/** @type {number} 查看其他位置 */
SEE_OTHER: 303,
/** @type {number} 临时重定向 */
TEMPORARY_REDIRECT: 307,
// 客户端错误响应 (400499)
/** @type {number} 错误请求 */
BAD_REQUEST: 400,
/** @type {number} 未授权 */
UNAUTHORIZED: 401,
/** @type {number} 禁止 */
FORBIDDEN: 403,
/** @type {number} 未找到 */
NOT_FOUND: 404,
/** @type {number} 方法禁用 */
METHOD_NOT_ALLOWED: 405,
/** @type {number} 不接受 */
NOT_ACCEPTABLE: 406,
/** @type {number} 请求超时 */
REQUEST_TIMEOUT: 408,
/** @type {number} 冲突 */
CONFLICT: 409,
/** @type {number} 已删除 */
GONE: 410,
/** @type {number} 负载过大 */
PAYLOAD_TOO_LARGE: 413,
/** @type {number} URI 过长 */
URI_TOO_LONG: 414,
/** @type {number} 不支持的媒体类型 */
UNSUPPORTED_MEDIA_TYPE: 415,
// 服务器错误响应 (500599)
/** @type {number} 服务器错误 */
INTERNAL_SERVER_ERROR: 500,
/** @type {number} 未实施 */
NOT_IMPLEMENTED: 501,
/** @type {number} 错误网关 */
BAD_GATEWAY: 502,
/** @type {number} 服务不可用 */
SERVICE_UNAVAILABLE: 503,
/** @type {number} 网关超时 */
GATEWAY_TIMEOUT: 504
}
module.exports = { HTTP_STATUS }