generated from neoncitylights/typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: some minor post cleanup (#26)
- package.json: remove directories key, only used for commonJS - package.json: add homepage key for exact path - add back README.md for typed-http - minor markdown style/formatting changes
- Loading branch information
1 parent
04b8586
commit fbb6295
Showing
5 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# @neoncitylights/typed-http | ||
|
||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT) | ||
[![npm (scoped)](https://img.shields.io/npm/v/@neoncitylights/typed-http?style=flat-square)](https://www.npmjs.com/package/@neoncitylights/typed-http) | ||
|
||
A pure TypeScript package that provides strongly typed HTTP headers, methods, and status codes. Supports the Fetch API, `XmlHttpRequest`, and the Node.js HTTP module with zero-runtime overhead. | ||
|
||
This package uses an open-source JSON dataset by [WebConcepts](https://webconcepts.info/JSON-concepts) with slight modifications, available under [`concepts.json`](./build/concepts.json). The script to auto-generate the TypeScript files is available under [`generateHttpTypes.ts`](./build/generateHttpTypes.ts). The generated files are: | ||
|
||
- [`httpHeaders.ts`](./src/httpHeaders.ts): 248 HTTP header types | ||
- [`httpMethods.ts`](./src/httpMethods.ts): 40 HTTP method types | ||
- [`httpStatusCodes.ts`](./src/httpStatusCodes.ts): 63 HTTP status code types | ||
|
||
## Install | ||
|
||
``` | ||
npm install @neoncitylights/typed-http | ||
``` | ||
|
||
## Documentation | ||
|
||
[Auto-generated API documentation is available.](https://neoncitylights.github.io/typed-http/) | ||
|
||
### API Reference | ||
> | ||
> **Note**: Specific HTTP headers, methods, and status codes are omitted from the API documentation for brevity. The full list of types is available in the source code. | ||
- `T`: <a href="#HttpHeader">#</a> headers.**HttpHeader** • [source](./src/httpHeaders.ts) | ||
- `T`: <a href="#HttpRequetHeader">#</a> headers.**HttpRequestHeader** • [source](./src/httpHeaders.ts) | ||
- `T`: <a href="#HttpResponseHeader">#</a> headers.**HttpResponseHeader** • [source](./src/httpHeaders.ts) | ||
- `T`: <a href="#ForbiddenHttpRequestHeader">#</a> headers.**ForbiddenHttpRequestHeader** • [source](./src/httpHeaders.ts) | ||
- `T`: <a href="#ForbiddenHttpResponseHeader">#</a> headers.**ForbiddenHttpResponseHeader** • [source](./src/httpHeaders.ts) | ||
- `T`: <a href="#HttpMethod">#</a> methods.**HttpMethod** • [source](./src/httpMethods.ts) | ||
- `T`: <a href="#HttpStatusCode">#</a> statusCodes.**HttpStatusCode** • [source](./src/httpStatusCodes.ts) | ||
- `T`: <a href="#HttpInfoStatusCode">#</a> statusCodes.**HttpInfoStatusCode** • [source](./src/httpStatusCodes.ts) | ||
- `T`: <a href="#HttpSuccessStatusCode">#</a> statusCodes.**HttpSuccessStatusCode** • [source](./src/httpStatusCodes.ts) | ||
- `T`: <a href="#HttpRedirectStatusCode">#</a> statusCodes.**HttpRedirectStatusCode** • [source](./src/httpStatusCodes.ts) | ||
- `T`: <a href="#HttpClientErrorStatusCode">#</a> statusCodes.**HttpClientErrorStatusCode** • [source](./src/httpStatusCodes.ts) | ||
- `T`: <a href="#HttpServerErrorStatusCode">#</a> statusCodes.**HttpServerErrorStatusCode** • [source](./src/httpStatusCodes.ts) | ||
|
||
## Usage | ||
|
||
### Type the Fetch API | ||
|
||
```ts | ||
import '@neoncitylights/typed-http/fetch'; | ||
|
||
let request = await fetch(); | ||
``` | ||
|
||
### Type `XmlHttpRequest` | ||
|
||
```ts | ||
import '@neoncitylights/typed-http/xhr'; | ||
|
||
const xhr = new XMLHttpRequest(); | ||
xhr.addEventListener('load', (e) => console.log(xhr.responseText)); | ||
xhr.open('GET', 'https://www.google.com'); | ||
xhr.send(); | ||
``` | ||
|
||
### Type the Node.js HTTP module | ||
|
||
```ts | ||
import '@neoncitylights/typed-http/node'; | ||
``` | ||
|
||
## License | ||
|
||
This library is licensed under the MIT license ([`LICENSE-MIT`](./LICENSE) or http://opensource.org/licenses/MIT). | ||
|
||
### Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters