awesome-static
v1.4.3
Published
Koa static file serving middleware base on [`koa-send`](https://github.com/koajs/send).
Downloads
17
Readme
Awesome-Static
Koa static file serving middleware base on koa-send
.
Feature
Some new features compared to koa-static.
- :monkey:Set the route map to static file directory
- :sunny:More than
GET
andHEAD
- :coffee: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