
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@metatypes/http-statuses
Advanced tools
@metatypes/http-statusesComplete, well-documented HTTP Status Code definitions for TypeScript Projects.
import { Statuses } from '@metatypes/http-statuses'
async function fetchUsers() {
	const response = await fetch(/* ... */)
	switch (response.status) {
		case Statuses.HTTP_200_OK:
			return response.data
		case Statuses.HTTP_404_NOT_FOUND:
			alert('the user could not be found')
			break
		default:
			throw new Error('Unknown API Error')
	}
}
For full-stack teams, it might be advantageous to use the same naming scheme on the front- and backend. So, you can also use framework-flavored status codes.
If you’d like to add another framework, feel free to submit a pull request or create an issue.
This is pretty much the same as the default Statuses enum, but status codes that aren’t supported by DRF are removed.
import { DRFStatuses } from '@metatypes/http-statuses'
async function fetchUsers() {
	const response = await fetch(/* ... */)
	switch (response.status) {
		case DRFStatuses.HTTP_200_OK:
			return response.data
		case DRFStatuses.HTTP_404_NOT_FOUND:
			alert('the user could not be found')
			break
		default:
			throw new Error('Unknown API Error')
	}
}
import { NodeJsStatuses } from '@metatypes/http-statuses'
async function fetchUsers() {
	const response = await fetch(/* ... */)
	switch (response.status) {
		case NodeJsStatuses.OK:
			return response.data
		case NodeJsStatuses.NotFound:
			alert('the user could not be found')
			break
		default:
			throw new Error('Unknown API Error')
	}
}
import { SpringStatuses } from '@metatypes/http-statuses'
async function fetchUsers() {
	const response = await fetch(/* ... */)
	switch (response.status) {
		case SpringStatuses.OK:
			return response.data
		case SpringStatuses.NotFound:
			alert('the user could not be found')
			break
		default:
			throw new Error('Unknown API Error')
	}
}
FAQs
Well-Documented HTTP Status Code Enums
The npm package @metatypes/http-statuses receives a total of 22 weekly downloads. As such, @metatypes/http-statuses popularity was classified as not popular.
We found that @metatypes/http-statuses demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.