maranda kao2 static middeware
Last updated a year ago by yu87109 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install maranda-koa2-static 
SYNC missed versions from official npm registry.


npm i --save maranda-koa2-static

this example is used for ts, if you are js user, if can use as almost the same, just delete the type define.


import Koa from 'koa';
import Koa2Static from 'maranda-koa2-static';
import {join as pathJoin} from 'path';

const app = new Koa();

app.use(Koa2Sataic<any, Ctx>([
  { root: filePath },
  { root: pathJoin(__dirname, '../../client/dist/web'), exclude: [/^\/graphql$/] }
], (ctx) => {
  ctx.body = 'not found'
}, true));
  • maxage Browser cache max-age in milliseconds.(defaults to 0)
  • immutable Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false)
  • hidden Allow transfer of hidden files. (defaults to false)
  • root Root directory to restrict file access.
  • index Name of the index file to serve automatically when visiting the root location. (defaults to none)
  • gzip Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. (defaults to true).
  • brotli Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. (defaults to true).
  • format If not false (defaults to true), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/.
  • setHeaders Function to set custom headers on response.
  • extensions Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false)

for more Versions, click see the changelog

Current Tags

  • 2.0.7                                ...           latest (a year ago)

11 Versions

  • 2.0.7                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2017 © |