koa-index
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

koa-index

Commitizen friendly

Serve directory listings for Koa

Install

NPM

Screenshot

screenshot

Usage

import Koa from 'koa'
import path from 'path'
import koaIndex from 'koa-index'

const app = new Koa()

app.use(
  koaIndex(__dirname, {
    hidden: true
  })
)

app.listen(8080)

API

interface IOpts {
  index?: string | boolean
  directory?: boolean
  maxAge?: number
  lastModified?: boolean
  etag?: boolean
  hidden?: boolean
}

koaIndex(root: string, opts?: IOpts)

Options

  • index: Default file name, defaults to index.html
  • directory: Support directory send, defaults to true
  • maxAge: cache control max age (in milliseconds) for the files, default to 0
  • lastModified: Enable or disable Last-Modified header, defaults to true
  • etag: Enable or disable etag generation, defaults to true
  • hidden: Display hidden (dot) files. Defaults to false

License

MIT

Package Sidebar

Install

npm i koa-index

Weekly Downloads

8

Version

0.2.0

License

MIT

Unpacked Size

53 kB

Total Files

35

Last publish

Collaborators

  • nashaofu