http-method-enum is a lightweight TypeScript package that provides a strongly typed enum for standard HTTP methods. Currently at version 1.0.0, it offers a consistent and error-resistant way to reference HTTP verbs (like GET, POST, PUT, DELETE, etc.) within TypeScript and JavaScript projects. This package aims to eliminate the use of 'magic strings' for HTTP methods, thereby improving code readability and maintainability, especially in applications that interact heavily with RESTful APIs. As a focused utility, its release cadence is tied primarily to any updates in HTTP method specifications, though it is generally stable and self-contained. It differentiates itself by providing a simple, declarative enum without additional runtime utilities.
npm install http-method-enumVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `HTTPMethod` enum for type-safe comparisons and conditional logic within a request handler function.
Always use `===` for comparison: `if (res.method === HTTPMethod.GET)`
No fix needed, this is by design. Just be aware that `HTTPMethod.GET === 'GET'` is true.
Remove any imports for `StatusCode` from `http-method-enum`. This package only exports `HTTPMethod`.
Correct the CommonJS import: `const { HTTPMethod } = require('http-method-enum');`Change the import statement to use named import syntax: `import { HTTPMethod } from 'http-method-enum';`Verify that the `import` or `require` statement correctly retrieves the `HTTPMethod` named export, ensuring it matches the module system (ESM or CommonJS) you are using.
Remove `StatusCode` from the import statement. This package only provides `HTTPMethod`.
No dependency data recorded yet.