Module

x/oak_commons/status.ts

A set of APIs for handling HTTP and HTTPS requests with Deno 🐿️ 🦕
Very Popular
Latest
import * as mod from "https://dotland.deno.dev/x/oak_commons@1.0.0/status.ts";

Contains the STATUS_CODE object which contains standard HTTP status codes and provides several type guards for handling status codes with type safety.

Examples

Example 1

import {
  STATUS_CODE,
  STATUS_TEXT,
} from "jsr:@oak/commons/status";

console.log(STATUS_CODE.NotFound); // Returns 404
console.log(STATUS_TEXT[STATUS_CODE.NotFound]); // Returns "Not Found"

Example 2

import { isErrorStatus } from "jsr:@oak/commons/status";

const res = await fetch("https://example.com/");

if (isErrorStatus(res.status)) {
  // error handling here...
}

Enums

Standard HTTP status codes.

Variables

A constant hash of all the standard HTTP status codes.

A record of all the status codes text.

Functions

A type guard that determines if the status code is a client error.

A type guard that determines if the status code is an error.

A type guard that determines if the status code is informational.

A type guard that determines if the status code is a redirection.

A type guard that determines if the status code is a server error.

A type guard that determines if the value is a valid StatusCode.

A type guard that determines if the status code is successful.

Type Aliases

An HTTP status that is a client error (4XX).

An HTTP status that is an error (4XX and 5XX).

An HTTP status that is a informational (1XX).

An HTTP status that is a redirect (3XX).

An HTTP status that is a server error (5XX).

A type alias which is a set of string literal types of all the status text values.

An HTTP status that is a success (2XX).