Socket
Book a DemoInstallSign in
Socket

http-codex

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-codex

HTTP status codes and methods based on Go's http library

latest
Source
npmnpm
Version
0.6.6
Version published
Maintainers
1
Created
Source

http-codex

A simple library for HTTP status codes and methods, adapted from Go's http package.

Usage

Install

# Install using your favorite package manager:
npm install http-codex
pnpm add http-codex
bun add http-codex
yarn add http-codex

Example

import { httpMethod, httpStatus } from 'http-codex'

const res = new Response('hello world!', {
  status: httpStatus.OK, // 200
  statusText: httpStatus.text(httpStatus.OK) // 'OK'
})

// HTTP methods
const method = httpMethod.GET // 'GET'

If preferred, status codes and methods can be imported by themselves to reduce bundle size:

import { httpMethod } from 'http-codex/method'
import { httpStatus } from 'http-codex/status'

const status = httpStatus.OK // 200
const method = httpMethod.POST // 'POST'

Additional Helpers

isNullBodyStatus

Helper function that returns whether the status should have a null body:

import { httpStatus, isNullBodyStatus } from 'http-codex'

const res = await fetch(url) // Might be 204, 304, etc.
return new Response(isNullBodyStatus(res.status) ? null : res.body, {
  // Useful for when we need to customize response headers/init/etc.
})

Bundle Size

Here are the bundle sizes of each import:

ImportMinifiedMinified + Gzip'd
http-codex4.1 KB1.46 KB
http-codex/status1.2 KB728 bytes
http-codex/method~200 bytes~150 bytes

Note: http-codex/status is smaller because it excludes the statusText() function. http-codex/method is the smallest as it only contains the HTTP method constants.

Why Another HTTP Status Code Library?

Honestly I just love Go and wanted one that was very similar to how Go's http package works.

Keywords

http status codes

FAQs

Package last updated on 21 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts