Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@poppanator/http-constants
Advanced tools
This package contains various HTTP constants: http status codes and texts, HTTP header names and HTTP methods, and a few related utility function.
This package contains various HTTP constants: http status codes and texts, HTTP header names and HTTP methods, and a few related utility function.
# NPM
npm i @poppanator/http-constants
# Yarn
yarn add @poppanator/http-constants
The following symbols are exported
status
Contains all possible HTTP status codes
import { status } from '@poppanator/http-constants'
status.Continue // 100
status.Ok // 200
status.Created // 201
// ...
status.NotFound // 404
// ...
status.InternalServerError // 500
// ... and so on
statusText
Contains all possible status texts
import { statusText } from '@poppanator/http-constants'
statusText.Continue // Continue
statusText.Ok // OK
statusText.Created // Created
// ...
statusText.NotFound // Not Found
// ...
statusText.InternalServerError // Internal Server Error
// ... and so on
tuple
Contains all status codes and texts as tuples where the first index is the status code and the second index the status text.
import { tuple } from '@poppanator/http-constants'
const [code, text] = tuple.Unauthorized // [401, 'Unauthorized']
const [code, text] = tuple.NotFound // [404, 'Not Found']
header
Contains all standardizes HTTP header names (and a few non- but defacto-standard ones).
import { header } from '@poppanator/http-constants'
header.AcceptEncoding // Accept-Encoding
header.IfModifiedSince // If-Modified-Since
header.AccessControlAllowMethods // Access-Control-Allow-Methods
method
Contains all standardized HTTP method names.
import { method, type Method } from '@poppanator/http-constants'
method.Post // POST
method.Options // OPTIONS
// ...
interface MyHttpInterface {
method: Method
}
const http: MyHttpInterface = {
method: 'FAKE', // Error
}
const http: MyHttpInterface = {
method: 'POST', // OK
}
Some utility functions are exported from the root of the package
import {
isInformational,
isSuccess,
isRedirect,
isClientError,
isServerError,
isHttpStatus,
getStatusText,
} from '@poppanator/http-constants'
// True for status codes in the 100-199 range
isInformational(100) // true
isInformational(102) // true
isInformational(201) // false
isInformational(403) // false
// True for status codes in the 200-299 range
isSuccess(200) // true
isSuccess(202) // true
isSuccess(100) // false
isSuccess(302) // false
// True for status codes in the 300-399 range
isRedirect(301) // true
isRedirect(307) // true
isRedirect(200) // false
isRedirect(500) // false
// True for status codes in the 400-499 range
isClientError(404) // true
isClientError(406) // true
isClientError(500) // false
isClientError(302) // false
// True for status codes in the 500-599 range
isServerError(500) // true
isServerError(503) // true
isServerError(200) // false
isServerError(308) // false
// True if the value is a known HTTP status code
isHttpStatus(201) // true
isHttpStatus(404) // true
isHttpStatus(503) // true
isHttpStatus(261) // false
isHttpStatus(210) // false
isHttpStatus(444) // false
// Returns the status code's corresponding status text
getStatusText(100) // Continue
getStatusText(201) // Created
getStatusText(304) // Not Modified
getStatusText(405) // Method Not Allowed
getStatusText(500) // Internal Server Error
FAQs
This package contains various HTTP constants: http status codes and texts, HTTP header names and HTTP methods, and a few related utility function.
The npm package @poppanator/http-constants receives a total of 49 weekly downloads. As such, @poppanator/http-constants popularity was classified as not popular.
We found that @poppanator/http-constants demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.