{"library":"status-code-enum","title":"HTTP Status Code Enum","type":"library","description":"status-code-enum is a TypeScript enum that provides a comprehensive collection of standard HTTP status codes. It is currently at version 1.0.0, indicating a stable API suitable for production use. The package utilizes `semantic-release`, suggesting a consistent, automated release cadence driven by commit messages; new versions are published as features or fixes are introduced rather than on a fixed calendar schedule. Its primary differentiation is its direct provision of these codes as a robust TypeScript enum, offering strong type safety and auto-completion benefits within TypeScript projects. This makes it a reliable and convenient alternative to using magic numbers or manually defining constants for HTTP responses. This approach significantly enhances code readability and maintainability by eliminating the need for developers to remember specific numeric codes or to repeatedly define them across various projects. The enum covers informational, success, redirection, client error, and server error codes as defined by HTTP standards.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install status-code-enum"],"cli":null},"imports":["import { StatusCode } from 'status-code-enum'","const { StatusCode } = require('status-code-enum')","import { StatusCode } from 'status-code-enum'; /* ... */ res.statusCode = StatusCode.ClientErrorBadRequest;"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/typeslick/status-code-enum","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/status-code-enum","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { StatusCode } from 'status-code-enum';\n\n// Example in a hypothetical HTTP response context (e.g., Node.js http module or framework)\ninterface HttpResponse {\n  statusCode: number;\n  send: (message: string) => void;\n}\n\nconst mockResponse: HttpResponse = {\n  statusCode: 200, // Default or initial status\n  send: (message: string) => console.log(`Sending response: ${message} (Status: ${mockResponse.statusCode})`)\n};\n\n// Setting a 400 Bad Request status\nmockResponse.statusCode = StatusCode.ClientErrorBadRequest;\nmockResponse.send(\"Your request was malformed.\");\n\n// Setting a 200 OK status\nmockResponse.statusCode = StatusCode.SuccessOK;\nmockResponse.send(\"Request processed successfully.\");\n\n// Setting a 404 Not Found status\nmockResponse.statusCode = StatusCode.ClientErrorNotFound;\nmockResponse.send(\"The requested resource could not be found.\");\n\n// Accessing the enum member directly\nconst unauthorizedCode: number = StatusCode.ClientErrorUnauthorized;\nconsole.log(`Unauthorized status code is: ${unauthorizedCode}`);\n","lang":"typescript","description":"Demonstrates how to import the `StatusCode` enum and assign its members to a hypothetical HTTP response object's status code, showcasing type-safe access to common HTTP codes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}