StatusFlowCodes constant provides a frozen object containing all available HTTP status codes as named constants. This allows you to use semantic names instead of numeric codes.
Object Type
Description
StatusFlowCodes is a frozen (immutable) object that maps HTTP status code names to their numeric values. The names are derived from the English names of the status codes, converted to uppercase with spaces replaced by underscores.Generation Mechanism
The constant is generated from the status code database using this transformation:- Take the English name of each status code (e.g., “Not Found”)
- Convert to uppercase
- Replace spaces with underscores
- Map to the numeric code
- “Not Found” →
NOT_FOUND: 404 - “Internal Server Error” →
INTERNAL_SERVER_ERROR: 500 - “Bad Request” →
BAD_REQUEST: 400
Available Status Codes
Informational (1xx)
Standard HTTP informational code.
Indicates protocol switching.
Request is being processed.
Early hints before final response.
Success (2xx)
Standard success response.
Resource successfully created.
Request accepted for processing.
Non-authoritative information.
Successful request with no content.
Reset content.
Partial content response.
Multiple status responses.
Already reported.
IM used.
Redirection (3xx)
Multiple choices available.
Resource moved permanently.
Resource found at different URI.
See other resource.
Resource not modified.
Temporary redirect.
Permanent redirect.
Client Errors (4xx)
Invalid request syntax.
Authentication required.
Payment required.
Access forbidden.
Resource not found.
HTTP method not allowed.
Not acceptable.
Request timeout.
Request conflicts with current state.
Resource permanently gone.
Request cannot be processed.
Rate limit exceeded.
Server Errors (5xx)
Internal server error.
Functionality not implemented.
Invalid gateway response.
Service temporarily unavailable.
Gateway timeout.
Examples
Using Named Constants
In Express Routes
With HTTP Exceptions
Validation Example
Getting All Available Codes
Benefits
- Type Safety: Avoid typos in status codes
- Readability: Code is self-documenting
- Maintainability: Easy to update if status codes change
- Consistency: Use the same naming convention across your codebase
- IDE Support: Autocomplete and IntelliSense work with named constants
Immutability
The object is frozen usingObject.freeze(), making it immutable:
Related
- StatusFlow Function - Use codes with StatusFlow
- HTTP Exceptions - Exception classes use these codes
- Middleware - Middleware works with status codes