# @iress/middy-http-path-router

> Routing middleware for Middy that provides path parameters in the event.

Latest version **0.2.0** (published 2023-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @iress/middy-http-path-router
pnpm add @iress/middy-http-path-router
yarn add @iress/middy-http-path-router
bun add @iress/middy-http-path-router
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-11-08 |
| First published | 2022-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rodney Marsh |
| Maintainers | testworksau, rodneymarshiress, rodneymarsh |

## Links

- npm: https://www.npmjs.com/package/@iress/middy-http-path-router
- Repository: https://github.com/iress/iress-middy-http-path-router
- Homepage: https://github.com/iress/iress-middy-http-path-router#readme
- Issues: https://github.com/iress/iress-middy-http-path-router/issues
- npm.io page: https://npm.io/package/@iress/middy-http-path-router

## Dependencies (2)

- [http-errors](https://npm.io/package/http-errors.md) ^2.0.0
- [route-recognizer](https://npm.io/package/route-recognizer.md) ^0.3.4

## Recent versions

- 0.2.0 (latest) — 2023-11-08
- 0.1.1 — 2022-07-27
- 0.1.0 — 2022-07-27

## README

# iress-middy-http-path-router
`@iress/middy-http-path-router` is middleware for [Middy](https://middy.js.org/) 
that routes API Gateway events to handlers based on static and dynamic paths.
For dynamic paths it will include the parameters within the `event.pathParameters`.

## Install
```shell
npm install @iress/middy-http-path-router
# or
yarn add @iress/middy-http-path-router
```

## Usage
```typescript
import { httpPathRouteHandler, Route } from '@iress/middy-http-path-router';

const routes: Route[] = [{
  method: 'GET',
  path: '/api/hello/:name',
  handler: (event: APIGatewayProxyEvent): APIGatewayProxyResult => {
    return {
      statusCode: 200,
      body: event.pathParameters?.name ?? 'anonymous'
    }
  }
}];

const handler = middy()
  .handler(httpPathRouteHandler(routes));
```

## More about routing
The responsibility for recognising routes and parameters is handled by 
[route-recognizer](https://github.com/tildeio/route-recognizer).

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