Gathering detailed insights and metrics for http-status-typed
Gathering detailed insights and metrics for http-status-typed
Gathering detailed insights and metrics for http-status-typed
Gathering detailed insights and metrics for http-status-typed
@tshttp/status
Ultra **typed**, over **documented**, and neatly **organised** HTTP status enums, to use for a great developper experience.
apiful
Extensible, typed API tooling
@se-oss/status-codes
Strongly typed HTTP status utilities for converting between status phrases and numeric codes.
@taktikorg/unde-animi-omnis
<p align="center"> <a href="https://www.npmjs.com/package/@taktikorg/unde-animi-omnis"><img src="https://img.shields.io/npm/v/@taktikorg/unde-animi-omnis"></a> <a href=""><img src="https://img.shields.io/github/actions/workflow/status/RemiMyrset/@taktikor
HTTP staus codes, but in a typescript enum so you have a parent type
npm install http-status-typed
Typescript
Module System
Min. Node Version
Node Version
NPM Version
71.4
Supply Chain
99.3
Quality
81.2
Maintenance
100
Vulnerability
99.6
License
TypeScript (99.27%)
JavaScript (0.73%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
9 Commits
1 Watchers
3 Branches
1 Contributors
Updated on Jun 03, 2025
Latest Version
3.0.0
Package Id
http-status-typed@3.0.0
Unpacked Size
26.88 kB
Size
9.86 kB
File Count
4
NPM Version
11.0.0
Node Version
20.17.0
Published on
Jun 03, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
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 enum
HTTP status codes are perfect candidates for const enums
because:
HttpStatusCode.OK
becomes 200
in your compiled JavaScript1npm install http-status-typed --save
1import { HttpStatusCode } from 'http-status-typed'; 2// or use an alias 3import Status from 'http-status-typed'; 4 5interface ApiResponse { 6 status: Status; 7 response: object; 8} 9 10function handleResponse(): ApiResponse { 11 return { 12 status: Status.OK, // Or use 200. Both are type valid. 13 response: { 14 body: '😎', 15 }, 16 }; 17} 18 19// Switch statements work perfectly 20function handleResponse(status: HttpStatusCode): string { 21 switch (status) { 22 case HttpStatusCode.OK: 23 return 'Success'; 24 case HttpStatusCode.NOT_FOUND: 25 return 'Not Found'; 26 case HttpStatusCode.INTERNAL_SERVER_ERROR: 27 return 'Server Error'; 28 default: 29 return 'Unknown'; 30 } 31} 32 33// Type safety with function parameters 34interface ApiResponse { 35 status: HttpStatusCode; 36 data: any; 37} 38 39function createResponse(status: HttpStatusCode, data: any): ApiResponse { 40 return { status, data }; 41} 42 43// Usage examples 44const successResponse = createResponse(HttpStatusCode.CREATED, { id: 123 }); 45const errorResponse = createResponse(HttpStatusCode.BAD_REQUEST, { 46 error: 'Invalid input', 47});
Your TypeScript:
1import { HttpStatusCode } from 'http-status-typed'; 2 3if (response.status === HttpStatusCode.OK) { 4 console.log('Success!'); 5}
Compiled JavaScript:
1if (response.status === 200 /* OK */) { 2 console.log('Success!'); 3}
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.):
1{ 2 "compilerOptions": { 3 "isolatedModules": true, 4 "preserveConstEnums": true // ← REQUIRED only for isolatedModules 5 } 6}
For regular TypeScript projects: No special configuration needed! Const enums work out of the box.
✅ Works with both CommonJS and ES Modules:
1// ES Modules (recommended) 2import { HttpStatusCode } from 'http-status-typed'; 3 4// CommonJS (also supported) 5import { 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
1// tsconfig.json 2{ 3 "compilerOptions": { 4 "isolatedModules": true, 5 "preserveConstEnums": true 6 } 7}
1// tsconfig.json 2{ 3 "compilerOptions": { 4 "isolatedModules": true, 5 "preserveConstEnums": true 6 } 7}
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:
1# Run tests 2npm test 3 4# Run tests in watch mode 5npm 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.
1# Install dependencies 2npm install 3 4# Build the project 5npm run build 6 7# Run tests 8npm test 9 10# Clean build artifacts 11npm run clean 12 13# Validate everything 14npm run validate
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
4 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More