# @haensl/http

> Simple JSON object of common HTTP headers, status codes and methods.

Latest version **1.1.1** (published 2024-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @haensl/http
pnpm add @haensl/http
yarn add @haensl/http
bun add @haensl/http
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-03-11 |
| First published | 2023-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | HP Dietz |
| Maintainers | haensl |
| Keywords | http, status, codes, status, methods, headers, data, map, JSON |

## Links

- npm: https://www.npmjs.com/package/@haensl/http
- Repository: https://github.com/haensl/http
- Homepage: https://github.com/haensl/http#readme
- Issues: https://github.com/haensl/http/issues
- Funding: https://github.com/sponsors/haensl
- npm.io page: https://npm.io/package/@haensl/http

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2024-03-11
- 1.1.0 — 2023-07-03
- 1.0.0 — 2023-06-13

## README

# @haensl/http

Simple JSON support module bundling common HTTP headers, status codes and methods.

[![NPM](https://nodei.co/npm/@haensl%2Fhttp.png?downloads=true)](https://nodei.co/npm/@haensl%2Fhttp/)

[![npm version](https://badge.fury.io/js/@haensl%2Fhttp.svg)](http://badge.fury.io/js/@haensl%2Fhttp)
[![CircleCI](https://circleci.com/gh/haensl/http.svg?style=svg)](https://circleci.com/gh/haensl/http)


## Installation

### Via `npm`

```bash
$ npm install -S @haensl/http
```

### Via `yarn`

```bash
$ yarn add @haensl/http
```

## Usage

1. [Install @haensl/http](#installation)

2. Use http status codes, methods and headers in your projects:


    ESM, i.e. `import`

    ```javascript
    import { statusCodes} from '@haensl/http';

    // ...
    const response = await fetch(url);

    if (response.statusCode < statusCodes.badRequest) {
      // do stuff when response status code < 400
    }

    // ...
    ```

    CJS, i.e. `require`

    ```javascript
    const { headers, methods } = require('@haensl/http');

    // ...
    const requestOptions = {
      headers: {
        [headers.contentType]: 'application/json'
      },
      method: methods.post,
      body: JSON.stringify(data)
    };

    const response = await fetch(url, requestOptions);

    // ...
    ```

## Synopsis

The `http` object is a simple JSON object that maps status codes, headers and strings:

```javascript
{
  "statusCodes": {
    "ok": 200,
    "created": 201,
    "accepted": 202,
    // ...
  },
  "headers": {
    "accept": "Accept",
    "accessControl": {
      "allow": {
        "origin": "Access-Control-Allow-Origin",
        "methods": "Access-Control-Allow-Methods"
        // ...
      },
      // ...
    },
    "authorization": "Authorization",
    "contentType": "Content-Type",
    // ...
  },
  "methods": {
    "delete": "delete",
    "get": "get",
    // ...
  }
}
```

### [JSON](index.json)

**Attention:** This JSON object is not exhaustive(, yet)! If you need a status code, header or method added, please [create a feature request](https://github.com/haensl/http/issues/new?labels=feature%20request)

## [Changelog](CHANGELOG.md)

---
_Source: https://npm.io/package/@haensl/http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
