Skip to content

A much better way to handle HTTP status codes in your applications. Zero dependencies, batteries included.

License

Notifications You must be signed in to change notification settings

touhidurrr/better-status-codes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c945d6d · Mar 23, 2025

History

24 Commits
Mar 23, 2025
Jan 19, 2025
May 6, 2024
Oct 4, 2024
Nov 15, 2024
Jan 19, 2025
Nov 3, 2024
Nov 3, 2024
Apr 23, 2024
Feb 21, 2025
Jan 19, 2025
Jan 19, 2025
May 6, 2024
May 6, 2024
Oct 4, 2024
May 6, 2024

better-status-codes NPM Downloads

A much better way to handle HTTP status codes in your applications. Zero dependencies, lightweight, and easy to use. Use the coding style of your choice! Typescript support out of the box!

Also supports status code of popular frameworks or services like AWS, Cloudflare, etc.

TS Example

Installation

bun add better-status-codes # bun
npm install better-status-codes # npm
yarn add better-status-codes # yarn
pnpm add better-status-codes # pnpm

Usage

Status Codes

import { Status } from "better-status-codes";

console.log(Status.OK); // 200
console.log(Status["Switching Protocols"]); // 101

// Screaming Snake Case Support
console.log(Status.SWITCHING_PROTOCOLS); // 101

// Or even this is allowed
console.log(Status[101]); // 101

Alias: Code (sounds nicer)

import { Code } from "better-status-codes";

console.log(Code.OK); // 200

Or use CommonJS modules!

const { Status } = require("better-status-codes");

Status Text

import { StatusText } from "better-status-codes";

console.log(StatusText.OK); // OK
console.log(StatusText["Switching Protocols"]); // Switching Protocols

// Screaming Snake Case Suppor
console.log(StatusText.SWITCHING_PROTOCOLS); // Switching Protocols

// Or even this is allowed
console.log(StatusText[101]); // Switching Protocols

Alias: Text, Reason, ReasonPhrase, Message or StatusMessage (Also used in many documentations to refer to the same thing)

import { Text } from "better-status-codes";

console.log(Text.I_AM_A_TEAPOT); // I'm a Teapot

For any issues or suggestions, please be my guest here.

About

A much better way to handle HTTP status codes in your applications. Zero dependencies, batteries included.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published