npm.io
1.4.3 • Published 7 years ago

awesome-static

Licence
MIT
Version
1.4.3
Deps
3
Size
7 kB
Vulns
0
Weekly
0

Awesome-Static Build Status npm TypeScript

Koa static file serving middleware base on koa-send.

Feature

Some new features compared to koa-static.

  • Set the route map to static file directory
  • More than GET and HEAD
  • Develop with Typescript

Installation

npm
npm install awesome-static
yarn
yarn add awesome-static

Usage

const Koa = require('koa');
const static = require('awesome-static');
const app = new Koa();

app.use(
  static('public', {
    allowMethods: ['GET', 'HEAD', 'POST'],
    route: 'hello',
  }),
);

app.listen(8080);

See /example.

API

AwesomeStatic(root, options);
  • root root directory string. nothing above this root directory can be served (Type: string).
  • options options object (Type:AwesomeOptions).
[Type] AwesomeOptions

Extends options from koa-static

  • route route for mapping to a static server (Type:string).
  • allowMethods HTTP method for allow access static file (Type:HTTPMethod).
[Type] HTTPMethod

GET | HEAD | POST | PUT | DELETE

License

MIT