
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
http-status-typed
Advanced tools
HTTP status codes as TypeScript const enum - zero bundle size, compile-time inlined values (TypeScript only)
A zero runtime size impact enums of HTTP status codes.
⚠️ Verify Configuration: Package only works with Typescript and projects using isolatedModules must enable preserveConstEnums
Utility to use HTTP status codes as an enum. Provides a better DX for readability and useability.
const enumHTTP status codes are perfect candidates for const enums because:
HttpStatusCode.OK becomes 200 in your compiled JavaScriptnpm install http-status-typed --save
import { HttpStatusCode } from 'http-status-typed';
// or use an alias
import Status from 'http-status-typed';
interface ApiResponse {
status: Status;
response: object;
}
function handleResponse(): ApiResponse {
return {
status: Status.OK, // Or use 200. Both are type valid.
response: {
body: '😎',
},
};
}
// Switch statements work perfectly
function handleResponse(status: HttpStatusCode): string {
switch (status) {
case HttpStatusCode.OK:
return 'Success';
case HttpStatusCode.NOT_FOUND:
return 'Not Found';
case HttpStatusCode.INTERNAL_SERVER_ERROR:
return 'Server Error';
default:
return 'Unknown';
}
}
// Type safety with function parameters
interface ApiResponse {
status: HttpStatusCode;
data: any;
}
function createResponse(status: HttpStatusCode, data: any): ApiResponse {
return { status, data };
}
// Usage examples
const successResponse = createResponse(HttpStatusCode.CREATED, { id: 123 });
const errorResponse = createResponse(HttpStatusCode.BAD_REQUEST, {
error: 'Invalid input',
});
Your TypeScript:
import { HttpStatusCode } from 'http-status-typed';
if (response.status === HttpStatusCode.OK) {
console.log('Success!');
}
Compiled JavaScript:
if (response.status === 200 /* OK */) {
console.log('Success!');
}
Notice how HttpStatusCode.OK becomes 200 with a helpful comment!
CONTINUE (100)SWITCHING_PROTOCOLS (101)PROCESSING (102)OK (200)CREATED (201)ACCEPTED (202)NON_AUTHORITATIVE_INFORMATION (203)NO_CONTENT (204)RESET_CONTENT (205)PARTIAL_CONTENT (206)MULTI_STATUS (207)ALREADY_REPORTED (208)IM_USED (226)MULTIPLE_CHOICES (300)MOVED_PERMANENTLY (301)FOUND (302)SEE_OTHER (303)NOT_MODIFIED (304)USE_PROXY (305)SWITCH_PROXY (306)TEMPORARY_REDIRECT (307)PERMANENT_REDIRECT (308)BAD_REQUEST (400)UNAUTHORIZED (401)PAYMENT_REQUIRED (402)FORBIDDEN (403)NOT_FOUND (404)METHOD_NOT_ALLOWED (405)NOT_ACCEPTABLE (406)PROXY_AUTHENTICATION_REQUIRED (407)REQUEST_TIMEOUT (408)CONFLICT (409)GONE (410)LENGTH_REQUIRED (411)PRECONDITION_FAILED (412)PAYLOAD_TOO_LARGE (413)URI_TOO_LONG (414)UNSUPPORTED_MEDIA_TYPE (415)RANGE_NOT_SATISFIABLE (416)EXPECTATION_FAILED (417)I_AM_A_TEAPOT (418)MISDIRECTED_REQUEST (421)UNPROCESSABLE_ENTITY (422)LOCKED (423)FAILED_DEPENDENCY (424)UPGRADE_REQUIRED (426)PRECONDITION_REQUIRED (428)TOO_MANY_REQUESTS (429)REQUEST_HEADER_FIELDS_TOO_LARGE (431)UNAVAILABLE_FOR_LEGAL_REASONS (451)INTERNAL_SERVER_ERROR (500)NOT_IMPLEMENTED (501)BAD_GATEWAY (502)SERVICE_UNAVAILABLE (503)GATEWAY_TIMEOUT (504)HTTP_VERSION_NOT_SUPPORTED (505)VARIANT_ALSO_NEGOTIATES (506)INSUFFICIENT_STORAGE (507)LOOP_DETECTED (508)NOT_EXTENDED (510)NETWORK_AUTHENTICATION_REQUIRED (511)Required: Your project must use TypeScript with proper configuration.
For projects using isolatedModules (Next.js 13+, Vite + SWC, etc.):
{
"compilerOptions": {
"isolatedModules": true,
"preserveConstEnums": true // ← REQUIRED only for isolatedModules
}
}
For regular TypeScript projects: No special configuration needed! Const enums work out of the box.
✅ Works with both CommonJS and ES Modules:
// ES Modules (recommended)
import { HttpStatusCode } from 'http-status-typed';
// CommonJS (also supported)
import { HttpStatusCode } from 'http-status-typed'; // compiles to CJS
The const enum values are inlined at compile time, so the module system doesn't matter at runtime.
✅ Fully Compatible (no config needed):
tsc)ts-loader⚠️ Requires Configuration:
preserveConstEnums: true)preserveConstEnums: true)isolatedModules❌ Not Compatible:
Version 1.0.1 significantly reduces the size of the package. Good for browsers now.
Version 1.0.2 supports both CommonJS and ES Modules but doubles the size of the package (since we're now publishing two files).
Version 2.0.0 only supports ES Modules.
Version 2.0.1 removes unneeded artifacts and reduces the size of the package.
Version 3.0.0 changes enum to const enum to reduce the runtime size of the package to 0kb. No longer supports JavaScript projects since there is not javascript exports. For more information, see TypeScript documentation.
If you were using the regular enum version:
preserveConstEnums: true if using isolatedModules// tsconfig.json
{
"compilerOptions": {
"isolatedModules": true,
"preserveConstEnums": true
}
}
// tsconfig.json
{
"compilerOptions": {
"isolatedModules": true,
"preserveConstEnums": true
}
}
No additional configuration needed - works out of the box!
Works with TypeScript template out of the box!
This package includes a comprehensive test suite validating all HTTP status codes:
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
Note: Coverage reporting is not applicable for const enums since they produce no runtime JavaScript code - all values are inlined at compile time.
A: Const enums provide zero runtime overhead while maintaining full type safety. For HTTP status codes that are compile-time constants, this is the perfect solution.
A: No, this package is now TypeScript-only. The compiled JavaScript is just export {}; because const enums are inlined.
A: You must set preserveConstEnums: true in your TypeScript configuration. This is required for Next.js 13+, Vite + SWC, and similar tools.
A: Only if you're using isolatedModules (Next.js 13+, Vite + SWC). Regular TypeScript projects work out of the box!
A: The API is identical to the previous enum version. Only the implementation changed to const enum.
A: Bundle size is now zero because const enums are compile-time constructs that get inlined as literals.
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Clean build artifacts
npm run clean
# Validate everything
npm run validate
MIT
FAQs
HTTP status codes as TypeScript const enum - zero bundle size, compile-time inlined values (TypeScript only)
The npm package http-status-typed receives a total of 193 weekly downloads. As such, http-status-typed popularity was classified as not popular.
We found that http-status-typed 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.