0.1.0 • Published 4 years ago

pambda-serve-static v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

pambda-serve-static

AWS Lambda 用 serve-static.

Installation

npm i pambda-serve-static -S

Usage

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

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

画像のようなバイナリーファイルを提供する時は、pambda-binary-support と組み合わせる必要がある。

serveStatic(root, options)

  • root
    • 静的ファイルが格納されているルートディレクトリのファイルシステム上のパス。
  • options.basePath
    • 静的ファイルを提供する基点となるパス。
  • options.index
    • ディレクトリをリクエストされた時に返すファイルのファイル名。
  • options.maxAge
    • レスポンスのキャッシュが有効な時間を秒単位で指定する。

License

MIT

0.1.0

4 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago