npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

swn-http-status

v1.0.5

Published

HTTPステータスコードをマジックナンバー化せずに扱えるシンプルなクラス。

Readme

HTTP Status パッケージ

このパッケージは、さまざまな HTTP ステータスコードを表す静的プロパティを持つシンプルな JavaScript/TypeScript クラス HTTPStatus を提供します。

インストール

npm でパッケージをインストールできます。

npm install swn-http-status

[!TIP] TypeScript プロジェクトでは型定義ファイル(.d.ts)も自動的に利用されます。

使い方

TypeScript の場合

import HTTPStatus from "swn-http-status";

console.log(HTTPStatus.OK); // 200
console.log(HTTPStatus.NotFound); // 404

JavaScript (ESModules) の場合

// ES Modules
import HTTPStatus from "swn-http-status";

console.log(HTTPStatus.OK); // 200
console.log(HTTPStatus.NotFound); // 404

JavaScript の場合 (CommonJS)

// CommonJS
const HTTPStatus = require("swn-http-status");

console.log(HTTPStatus.OK); // 200
console.log(HTTPStatus.NotFound); // 404

[!NOTE] CommonJS で利用する場合も require("swn-http-status") で直接 HTTPStatus.OK のようにアクセスできます。

HTTP ステータスコード一覧

HTTPStatus クラスには、以下のステータスコードが含まれています。

| コード | 名前 | 説明 | | -----: | :---------------------------- | :---------------------------------------------------------------------------------------------------------------- | | 100 | Continue | サーバーはリクエストヘッダーを受信し、クライアントはリクエストを続行できます。 | | 101 | SwitchingProtocols | サーバーがプロトコルの切り替えを承認したことを示します。 | | 102 | Processing | WebDAV 拡張。リクエストの処理が継続中であることを示します。 | | 103 | EarlyHints | レスポンスヘッダーの早期通知に使用されます。 | | 200 | OK | リクエストが正常に成功しました。 | | 201 | Created | 新しいリソースが作成されました。 | | 202 | Accepted | リクエストは受理されましたが、まだ処理されていません。 | | 203 | NonAuthoritativeInformation | オリジンサーバー以外からの情報を返します。 | | 204 | NoContent | レスポンスボディがありません。 | | 205 | ResetContent | クライアントはフォームなどをリセットする必要があります。 | | 206 | PartialContent | 部分的なレスポンスを返します(範囲リクエスト)。 | | 207 | MultiStatus | WebDAV 拡張。複数のステータスを返します。 | | 208 | AlreadyReported | WebDAV 拡張。すでに報告済みのリソースです。 | | 226 | IMUsed | インスタントメッセージングで使用される拡張コードです。 | | 300 | MultipleChoices | 複数の選択肢が存在します。 | | 301 | MovedPermanently | リソースが恒久的に移動しました。 | | 302 | Found | リソースが一時的に移動しました。 | | 303 | SeeOther | 他の URI を参照してください。 | | 304 | NotModified | リソースは変更されていません。 | | 305 | UseProxy | プロキシを使用する必要があります。 | | 307 | TemporaryRedirect | 一時的にリダイレクトされます。 | | 308 | PermanentRedirect | 恒久的にリダイレクトされます。 | | 400 | BadRequest | サーバーがリクエストを理解できません。不正な構文やパラメータの場合に返されます。 | | 401 | Unauthorized | 認証が必要ですが、認証情報が提供されていないか無効です。 | | 402 | PaymentRequired | 支払いが必要な場合に使用されます(現在は予約されています)。 | | 403 | Forbidden | サーバーがリクエストを理解したが、権限がないため拒否されました。 | | 404 | NotFound | サーバーは要求されたリソースを見つけることができません。ブラウザでは、これは URL が認識されないことを意味します。 | | 405 | MethodNotAllowed | リクエストメソッドがサポートされていません。 | | 406 | NotAcceptable | リクエストしたリソースが Accept ヘッダーで許可されていません。 | | 407 | ProxyAuthenticationRequired | プロキシ認証が必要です。 | | 408 | RequestTimeout | サーバーがクライアントからのリクエストをタイムアウトしました。 | | 409 | Conflict | リクエストが現在のリソースの状態と競合しています。 | | 410 | Gone | リクエストされたリソースは恒久的に削除されました。 | | 411 | LengthRequired | Content-Length ヘッダーが必要です。 | | 412 | PreconditionFailed | 前提条件が失敗しました。 | | 413 | PayloadTooLarge | リクエストペイロードが大きすぎます。 | | 414 | URITooLong | リクエスト URI が長すぎます。 | | 415 | UnsupportedMediaType | サポートされていないメディアタイプです。 | | 416 | RangeNotSatisfiable | リクエストした範囲が満たせません。 | | 417 | ExpectationFailed | Expect ヘッダーで指定された期待値にサーバーが応えられません。 | | 418 | ImATeapot | エイプリルフールのジョークコードです。ティーポットはコーヒーを淹れられません。 | | 421 | MisdirectedRequest | リクエストが誤ったサーバーに送信されました。 | | 422 | UnprocessableEntity | リクエストは理解できたが処理できません(バリデーションエラー等)。 | | 423 | Locked | リソースがロックされています。 | | 424 | FailedDependency | 依存関係の失敗によりリクエストが失敗しました。 | | 425 | TooEarly | リクエストが早すぎます。 | | 426 | UpgradeRequired | プロトコルのアップグレードが必要です。 | | 428 | PreconditionRequired | 前提条件が必要です。 | | 429 | TooManyRequests | リクエストが多すぎます(レートリミット)。 | | 431 | RequestHeaderFieldsTooLarge | リクエストヘッダーが大きすぎます。 | | 451 | UnavailableForLegalReasons | 法的理由により利用できません。 | | 500 | InternalServerError | サーバー内部で予期しないエラーが発生しました。 | | 501 | NotImplemented | サーバーがリクエストされた機能を実装していません。 | | 502 | BadGateway | サーバーが不正なレスポンスを受け取りました。 | | 503 | ServiceUnavailable | サービスが一時的に利用できません。 | | 504 | GatewayTimeout | ゲートウェイまたはプロキシがタイムアウトしました。 | | 505 | HTTPVersionNotSupported | サーバーがリクエストされた HTTP バージョンをサポートしていません。 | | 506 | VariantAlsoNegotiates | ネゴシエーションエラーが発生しました。 | | 507 | InsufficientStorage | サーバーのストレージ容量が不足しています。 | | 508 | LoopDetected | サーバーが無限ループを検出しました。 | | 510 | NotExtended | 拡張が必要です。 | | 511 | NetworkAuthenticationRequired | ネットワーク認証が必要です。 |

更新履歴

| バージョン | 日付 | 主な変更点 | | :--------: | :--------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 1.0.5 | 2025-06-10 | HTTP ステータスコードから名前を取得できる HTTPStatus.Name(statusCode: number): string | undefined 静的メソッドを追加全コード・全名称の相互変換テストを追加 | | 1.0.4 | 2025-05-23 | CommonJS での利用方法を HTTPStatus.default.OK から HTTPStatus.OK へ変更 | | 1.0.3 | 2025-05-23 | ESModule 対応関連の修正を行いました | | 1.0.2 | 2025-05-23 | ビルド成果物の配置と npm scripts を整理し、ESModule と CommonJS 両対応をより明確にdist/src/ 配下に ESM・CJS 両方のエントリポイントを配置package.jsonexports 設定を修正 | | 1.0.1 | 2025-05-22 | README の「使い方」で、ESModules と CommonJS の場合を分けて記載 | | 1.0.0 | 2025-05-21 | 初回リリース |

ライセンス

このプロジェクトは MIT ライセンスの下で公開されています。詳細は LICENSE ファイルをご覧ください。