x/status@0.1.0

🗿 HTTP status utility for Deno. Based on Java Apache HttpStatus
GitHub Stars
11
Latest
import * as status from "https://deno.land/x/status@0.1.0/mod.ts";

Variables

ACCEPTED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.3

ALL

Array with all the supported status codes.

BAD_GATEWAY

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.3

BAD_REQUEST

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.1

CONFLICT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.8

CONTINUE

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1

CREATED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.2

EXPECTATION_FAILED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.14

FAILED_DEPENDENCY

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.5

FORBIDDEN

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.3

GATEWAY_TIMEOUT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.5

GONE

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.9

HTTP_VERSION_NOT_SUPPORTED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.6

IM_A_TEAPOT

Official Documentation @ https://tools.ietf.org/html/rfc2324#section-2.3.2

INSUFFICIENT_SPACE_ON_RESOURCE

UNOFFICIAL w/ NO DOCS

INSUFFICIENT_STORAGE

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.6

INTERNAL_SERVER_ERROR

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.1

LENGTH_REQUIRED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.10

LOCKED

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.4

METHOD_FAILURE 👎 deprecated
METHOD_NOT_ALLOWED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.5

MOVED_PERMANENTLY

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.2

MOVED_TEMPORARILY

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.3

MULTI_STATUS

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.2

MULTIPLE_CHOICES

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.1

NETWORK_AUTHENTICATION_REQUIRED

Official Documentation @ https://tools.ietf.org/html/rfc6585#section-6

NO_CONTENT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.5

NON_AUTHORITATIVE_INFORMATION

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.4 This response code means returned meta-information set is not exact set as available from the origin server, but collected from a local or a third party copy. Except this condition, 200 OK response should be preferred instead of this response.

NOT_ACCEPTABLE

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.6

NOT_FOUND

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.4

NOT_IMPLEMENTED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.2

NOT_MODIFIED

Official Documentation @ https://tools.ietf.org/html/rfc7232#section-4.1

OK

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.1

PARTIAL_CONTENT

Official Documentation @ https://tools.ietf.org/html/rfc7233#section-4.1

PAYMENT_REQUIRED

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.2

PERMANENT_REDIRECT

Official Documentation @ https://tools.ietf.org/html/rfc7538#section-3

PRECONDITION_FAILED

Official Documentation @ https://tools.ietf.org/html/rfc7232#section-4.2

PRECONDITION_REQUIRED

Official Documentation @ https://tools.ietf.org/html/rfc6585#section-3

PROCESSING

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.1

PROXY_AUTHENTICATION_REQUIRED

Official Documentation @ https://tools.ietf.org/html/rfc7235#section-3.2

REQUEST_HEADER_FIELDS_TOO_LARGE

Official Documentation @ https://tools.ietf.org/html/rfc6585#section-5

REQUEST_TIMEOUT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.7

REQUEST_TOO_LONG

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.11

REQUEST_URI_TOO_LONG

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.12

REQUESTED_RANGE_NOT_SATISFIABLE

Official Documentation @ https://tools.ietf.org/html/rfc7233#section-4.4

RESET_CONTENT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.3.6

SEE_OTHER

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.4

SERVICE_UNAVAILABLE

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.6.4

SWITCHING_PROTOCOLS

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.2

TEMPORARY_REDIRECT

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.4.7

TOO_MANY_REQUESTS

Official Documentation @ https://tools.ietf.org/html/rfc6585#section-4

UNAUTHORIZED

Official Documentation @ https://tools.ietf.org/html/rfc7235#section-3.1

UNPROCESSABLE_ENTITY

Official Documentation @ https://tools.ietf.org/html/rfc2518#section-10.3

UNSUPPORTED_MEDIA_TYPE

Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.5.13

USE_PROXY 👎 deprecated

Functions

status

Get the status code.

status

Open Issues GitHub license Deno Version Deno Doc

HTTP codes and status utility for Deno. Based on Java Apache HttpStatus

API

status(code) and status.pretty(code)

import { status } from "https://deno.land/x/status/mod.ts";

status(403) // => "FORBIDDEN"
status("403") // => "FORBIDDEN"
status.pretty(403) // => "Forbidden"
status(306) // throws

status(message)

import { status } from "https://deno.land/x/status/mod.ts";

status("forbidden") // => 403
status("FoRbIdDeN") // => 403
status("foo") // throws

status.codes

Array of all the possible status codes.

import { status } from "https://deno.land/x/status/mod.ts";

status.codes; // => [202, 502, 400, ...]

status.code[code]

Map of all the available codes. message (string) -> code (number)

import { status } from "https://deno.land/x/status/mod.ts";

status.code; // => { "ACCEPTED": 202, "BAD_GATEWAY": 502, "BAD_REQUEST": 400, ... }
satuus.code["FORBIDDEN"] = 403;

status.message[msg]

Map of all the available codes. code (number) -> message (string)

import { status } from "https://deno.land/x/status/mod.ts";

status.message; // => { 202: "ACCEPTED", 502: "BAD_GATEWAY, 400: "BAD_REQUEST", ... }
status.message[403] = "FORBIDDEN";

status.empty[code]

Returns true if a status code exprects an empty body.

import { status } from "https://deno.land/x/status/mod.ts";

status.empty[200] // => undefined
status.empty[204] // => true

status.redirect[code]

Returns true if a status code is a valid redirect status.

import { status } from "https://deno.land/x/status/mod.ts";

status.redirect[200] // => undefined
status.redirect[301] // => true

status.retry[code]

Returns true if a status code hints that the request might be retried.

import { status } from "https://deno.land/x/status/mod.ts";

status.retry[501] // => undefined
status.retry[503] // => true

other

contribution

Pull request and issues are very welcome. Code style is formatted with deno fmt.

inspiration

The project is inspired by the statuses project.