Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denosaurs/status
🗿 HTTP status utility for Deno. Based on Java Apache HttpStatus
https://github.com/denosaurs/status
deno http status
Last synced: 2 months ago
JSON representation
🗿 HTTP status utility for Deno. Based on Java Apache HttpStatus
- Host: GitHub
- URL: https://github.com/denosaurs/status
- Owner: denosaurs
- License: mit
- Created: 2020-05-16T07:46:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T17:05:36.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T23:09:44.931Z (8 months ago)
- Topics: deno, http, status
- Language: TypeScript
- Homepage: https://deno.land/x/status
- Size: 21.5 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno-cn - @denosaurs/status
- awesome-deno - status - HTTP codes and status utility for Deno.![GitHub stars](https://img.shields.io/github/stars/denosaurs/status?style=plastic) (Modules / Online Playgrounds)
- awesome-deno - status - HTTP codes and status utility for Deno. (Modules / Web utils)
README
# status
[![Open Issues](https://img.shields.io/github/issues/denosaurs/status)](https://github.com/denosaurs/status)
[![GitHub license](https://img.shields.io/github/license/denosaurs/status)](https://github.com/denosaurs/denom/blob/master/LICENSE)
[![Deno Version](https://img.shields.io/badge/deno-1.0.0-informational)](https://deno.land)
[![Deno Doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/status/mod.ts)HTTP codes and status utility for Deno. Based on
[Java Apache HttpStatus](http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpStatus.html)## API
### status(code) and status.pretty(code)
```typescript
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)
```typescript
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.
```typescript
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)`
```typescript
import { status } from "https://deno.land/x/status/mod.ts";status.code; // => { "ACCEPTED": 202, "BAD_GATEWAY": 502, "BAD_REQUEST": 400, ... }
status.code["FORBIDDEN"] = 403;
```### status.message[msg]
Map of all the available codes. `code (number) -> message (string)`
```typescript
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 expects an empty body.
```typescript
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.
```typescript
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.
```typescript
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](https://github.com/jshttp/statuses)
project.