UNPKG

@tsed/schema

Version:
18 lines (17 loc) 591 B
import { constantCase } from "change-case"; import statuses from "statuses"; export const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map, code) => { const message = String(statuses(code)); return { ...map, [String(code)]: { label: message, code: constantCase(message) } }; }, {}); HTTP_STATUS_MESSAGES["200"].label = "Success"; HTTP_STATUS_MESSAGES["200"].code = "SUCCESS"; export function getStatusConstant(status) { return HTTP_STATUS_MESSAGES[status]?.code; } export function getStatusMessage(status) { return HTTP_STATUS_MESSAGES[status]?.label; }