# pambda-serve-static

> Serve static files for AWS Lambda

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

## Install

```sh
npm install pambda-serve-static
pnpm add pambda-serve-static
yarn add pambda-serve-static
bun add pambda-serve-static
```

## 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.0 |
| Published | 2020-08-16 |
| First published | 2017-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kengo Nakatsuka |
| Maintainers | nak2k |
| Keywords | aws, lambda, pambda |

## Links

- npm: https://www.npmjs.com/package/pambda-serve-static
- Repository: https://github.com/pambda/pambda-serve-static
- Issues: https://github.com/pambda/pambda-serve-static/issues
- npm.io page: https://npm.io/package/pambda-serve-static

## Dependencies (2)

- [mime-types](https://npm.io/package/mime-types.md) ^2.1.18
- [lambda-callbackify](https://npm.io/package/lambda-callbackify.md) 0.0.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-08-16
- 0.0.5 — 2018-04-18
- 0.0.4 — 2018-03-15
- 0.0.3 — 2017-06-11
- 0.0.2 — 2017-05-23
- 0.0.1 — 2017-05-22

## README

# pambda-serve-static

Serve static files for AWS Lambda.

## Installation

```
npm i pambda-serve-static
```

## Usage

``` javascript
const { compose, createLambda } = require('pambda');
const { binarySupport } = require('pambda-binary-support');
const { cache } = require('pambda-cache');
const { serveStatic } = require('pambda-serve-static');

exports.handler = createLambda(
  compose(
    cache(),
    binarySupport({
      binaryMediaTypes: [ 'image/*' ],
    }),
    serveStatic('public', {
      basePath: '/',
      index: [ 'index.htm', 'index.html' ],
      maxAge: 60 * 60 * 24,
    })
  )
);
```

When serving binary files like images, you need to combine with [pambda-binary-support](https://github.com/pambda/pambda-binary-support).

## serveStatic(root, options)

- `root`
    - The path on the file system of the root directory where static files are stored.
- `options.basePath`
    - The base path that serves static files.
- `options.index`
    - The file name of the file to return when the directory is requested.
- `options.maxAge`
    - Specify the time in seconds for which the response cache is available.

## License

MIT

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