Skip to content

Instantly share code, notes, and snippets.

@jessejjohnson
Created June 14, 2025 05:38
Show Gist options
  • Save jessejjohnson/14441b43da6a9b6e65d45da6e635e8df to your computer and use it in GitHub Desktop.
Save jessejjohnson/14441b43da6a9b6e65d45da6e635e8df to your computer and use it in GitHub Desktop.
Typed HTTP Status Codes
export type InfoStatusCode = 100 | 101 | 102 | 103
export type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226
export type DeprecatedStatusCode = 305 | 306
export type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308
export type ClientErrorStatusCode =
| 400
| 401
| 402
| 403
| 404
| 405
| 406
| 407
| 408
| 409
| 410
| 411
| 412
| 413
| 414
| 415
| 416
| 417
| 418
| 421
| 422
| 423
| 424
| 425
| 426
| 428
| 429
| 431
| 451
export type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511
export type UnofficialStatusCode = -1
export type StatusCode =
| InfoStatusCode
| SuccessStatusCode
| RedirectStatusCode
| ClientErrorStatusCode
| ServerErrorStatusCode
| UnofficialStatusCode
export type ContentlessStatusCode = 101 | 204 | 205 | 304
export type ContentfulStatusCode = Exclude<StatusCode, ContentlessStatusCode>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment