The http-status-lite is a lightweight and comprehensive utility providing standardized HTTP status codes for applications. It simplifies the handling of HTTP response codes by offering predefined constants, ensuring clarity and consistency in API responses.
- Predefined HTTP Status Codes: Provides a comprehensive set of HTTP status codes for easy reference.
- TypeScript Support: Includes strong type definitions for enhanced code safety and developer experience.
- Immutable Constants: Ensures status codes cannot be modified, preventing unintended changes.
- Lightweight & Efficient: Minimal footprint with high performance.
- Easy Integration: Seamlessly integrates with any Node.js or TypeScript-based project.
To install the package, run the following command:
npm install http-status-liteor
yarn add http-status-liteor
pnpm add http-status-liteor
bun add http-status-liteconst httpStatusLite = require('http-status-lite');
console.log(httpStatusLite.OK); // Outputs: 200import httpStatusLite from 'http-status-lite';
console.log(httpStatusLite.OK); // Outputs: 200
const successStatus: HttpStatusType = 'OK';
console.log(httpStatusLite[successStatus]); // Outputs: 200import httpStatusLite, { HttpStatusType } from 'http-status-lite';
console.log(httpStatusLite.OK); // Outputs: 200
const successStatus: HttpStatusType = 'OK';
console.log(httpStatusLite[successStatus]); // Outputs: 200CONTINUE: 100SWITCHING_PROTOCOLS: 101PROCESSING: 102EARLY_HINTS: 103
OK: 200CREATED: 201ACCEPTED: 202NO_CONTENT: 204PARTIAL_CONTENT: 206
MULTIPLE_CHOICES: 300MOVED_PERMANENTLY: 301FOUND: 302SEE_OTHER: 303TEMPORARY_REDIRECT: 307PERMANENT_REDIRECT: 308
BAD_REQUEST: 400UNAUTHORIZED: 401FORBIDDEN: 403NOT_FOUND: 404METHOD_NOT_ALLOWED: 405TOO_MANY_REQUESTS: 429UNAVAILABLE_FOR_LEGAL_REASONS: 451
INTERNAL_SERVER_ERROR: 500NOT_IMPLEMENTED: 501BAD_GATEWAY: 502SERVICE_UNAVAILABLE: 503GATEWAY_TIMEOUT: 504
This project is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).
- Share — Copy and redistribute the material in any medium or format.
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial — You may not use the material for commercial purposes.
- NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.
For more details, please visit the Creative Commons License Page.
Special thanks to the following resources:
- MDN Web Docs - Comprehensive HTTP status code references.
- Node.js Express Documentation - Guidance on handling HTTP responses.
- TypeScript Docs - Best practices for defining and using type-safe constants.
HTTP status codes are categorized based on their meaning. Informational (100s), Success (200s), Redirection (300s), Client Errors (400s), and Server Errors (500s). Choose the appropriate category based on your response type.
No, the constants are immutable and follow the official HTTP status codes. If needed, you can create a wrapper module to include your custom codes.
You can remove the package by running:
npm uninstall http-status-liteor
yarn remove http-status-liteor
pnpm remove http-status-liteor
bun remove http-status-lite|
M♢NTΛSIM |
