# @types/itty-router-extras

> TypeScript definitions for itty-router-extras

Latest version **0.4.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/itty-router-extras
pnpm add @types/itty-router-extras
yarn add @types/itty-router-extras
bun add @types/itty-router-extras
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2023-11-07 |
| First published | 2021-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/itty-router-extras
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/itty-router-extras
- npm.io page: https://npm.io/package/@types/itty-router-extras

## Dependencies (1)

- [itty-router](https://npm.io/package/itty-router.md) ^2.3.10

## Recent versions

- 0.4.3 (latest) — 2023-11-07
- 0.4.0 (ts3.6) — 2021-08-10
- 0.4.2 — 2023-10-18
- 0.4.1 — 2023-09-26

## README

# Installation
> `npm install --save @types/itty-router-extras`

# Summary
This package contains type definitions for itty-router-extras (https://github.com/kwhitley/itty-router-extras).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/itty-router-extras.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/itty-router-extras/index.d.ts)
````ts
import { Request as IttyRequest, Router } from "itty-router";
export { Router as ThrowableRouter };

/**
 * Throw to respond with provided status code and message.
 */
export class StatusError extends Error {
    constructor(status: number, message: string);
}

/**
 * Middleware to safely parse and embed content request bodies (eg.text/json) as `request.content`.
 */
export function withContent(request: IttyRequest): void;

/**
 * Middleware to embed cookies into request as `request.cookies` (object).
 */
export function withCookies(request: IttyRequest): void;

/**
 * Middleware to embed route params directly into request as a convenience.
 *
 * NOTE: withParams cannot be applied globally upstream, as it will have seen no route params at this stage (to spread into the request).
 */
export function withParams(request: IttyRequest): void;

export interface ErrorBody {
    error: string;
    status: number;
}

/**
 * Create JSON-formatted {@link Response}, with {@link ErrorBody} or custom payload as body.
 *
 * @param status Response status code
 * @param payload Error message or custom payload
 */
export function error(status: number, payload?: string | object): Response;

/**
 * Create JSON-formatted {@link Response Response}.
 *
 * @param content Payload
 * @param options Response options
 */
export function json(content: object, options?: ResponseInit): Response;

/**
 * Create JSON-formatted {@link Response}, with status code 404, and message as {@link ErrorBody} or custom payload.
 *
 * @param payload Error message or custom payload
 */
export function missing(payload?: string | object): Response;

export interface StatusBody {
    message: string;
    status: number;
}

/**
 * Create JSON-formatted {@link Response}, with provided status code and message as {@link StatusBody body} or custom payload.
 *
 * @param status Response status code
 * @param message Message or custom payload
 */
export function status(status: number, payload?: string | object): Response;

/**
 * Create plaintext-formatted {@link Response} with provided options.
 *
 * @param content Response text
 * @param options Response options
 */
export function text(content: string, options?: ResponseInit): Response;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
 * Dependencies: [itty-router](https://npmjs.com/package/itty-router)

# Credits
These definitions were written by [David Roizenman](https://github.com/hmnd).

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