1.4.3 • Published 7 years ago
awesome-static v1.4.3
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 GETandHEAD
- :coffee:Develop with Typescript
Installation
npm
npm install awesome-staticyarn
yarn add awesome-staticUsage
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);- rootroot directory string. nothing above this root directory can be served (Type:- string).
- optionsoptions object (Type:- AwesomeOptions).
Type AwesomeOptions
Extends options from koa-static
- routeroute for mapping to a static server (Type:- string).
- allowMethodsHTTP method for allow access static file (Type:- HTTPMethod).
Type HTTPMethod
GET | HEAD | POST | PUT | DELETE
License
MIT