# lambda-url-resolver

> URL resolver for Lambda

Latest version **0.1.6** (published 2020-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install lambda-url-resolver
pnpm add lambda-url-resolver
yarn add lambda-url-resolver
bun add lambda-url-resolver
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2020-08-16 |
| First published | 2019-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kengo Nakatsuka |
| Maintainers | nak2k |

## Links

- npm: https://www.npmjs.com/package/lambda-url-resolver
- Repository: https://github.com/nak2k/node-lambda-url-resolver
- Issues: https://github.com/nak2k/node-lambda-url-resolver/issues
- npm.io page: https://npm.io/package/lambda-url-resolver

## Dependencies (1)

- [caseless-get](https://npm.io/package/caseless-get.md) ^0.1.0

## Recent versions

- 0.1.6 (latest) — 2020-08-16
- 0.1.5 — 2020-08-16
- 0.1.4 — 2020-08-09
- 0.1.3 — 2019-07-02
- 0.1.2 — 2019-05-14
- 0.1.1 — 2019-03-30
- 0.1.0 — 2019-03-30

## README

# lambda-url-resolver

URL resolver for Lambda.

In building the web site with API Gateway + Lambda, this package is useful that generates redirect URLs.

## Installation

```
npm i lambda-url-resolver
```

## API

### getBasePath(event, options)

This function returns a base path for an event.

- `event`
  - An event object of Lambda Proxy Integration.
- `options.basePathMap`
  - See `resolveUrl(url, event, options)`

### getCurrentUrl(event, options)

This function is equivalent to `resolveUrl(event.path, event, options)`.

### resolvePath(path, event, options)

This function resolve a path and return an absolute path.
In order to do it, get a base path from `event` and `options`.

- `path`
  - A relative path.
- `event`
  - An event object of Lambda Proxy Integration.
- `options.basePathMap`
  - See `resolveUrl(url, event, options)`

### resolveUrl(url, event, options)

This function resolve a url and return an absolute url.

- `url`
  - A relative url.
- `event`
  - An event object of Lambda Proxy Integration.
- `options.basePathMap`
  - An object that specify base paths for each domains.
  - The key is a domain, and the value is a base path against the domain.
  - If the value of the host header of the event does not match any key of this object, the following process make the base path:
    - If the value of the host header ends with `.amazonaws.com`, the base path is `/${event.requestContext.stage}/`.
    - Otherwise, the base path is `/`.
  - Default: `{}`

## Related

- [pambda-redirect](https://github.com/pambda/pambda-redirect)

## License

MIT

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