# koa-static-folder

> Static file server based on a folder instead of a single file. Node needs to be restarted in order to work through file caching.

Latest version **0.1.6** (published 2015-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-static-folder
pnpm add koa-static-folder
yarn add koa-static-folder
bun add koa-static-folder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2015-11-29 |
| First published | 2014-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Jan-Pieter Zoutewelle |
| Maintainers | janpieterz |

## Links

- npm: https://www.npmjs.com/package/koa-static-folder
- Repository: https://github.com/janpieterz/koajs-static-folder
- Homepage: https://github.com/janpieterz/koajs-static-folder#readme
- Issues: https://github.com/janpieterz/koajs-static-folder/issues
- npm.io page: https://npm.io/package/koa-static-folder

## Dependencies (2)

- [koa](https://npm.io/package/koa.md) ~0.5.1
- [koa-send](https://npm.io/package/koa-send.md) ~1.2.4

## Recent versions

- 0.1.6 (latest) — 2015-11-29
- 0.1.5 — 2015-01-06
- 0.1.4 — 2015-01-06
- 0.1.3 — 2014-11-27
- 0.1.2 — 2014-08-22
- 0.1.1 — 2014-04-15
- 0.1.0 — 2014-04-15

## README

# koajs-static-folder

Middleware for KoaJS to serve a folder as static files. Other implementations require every file to be appointed individually (as far as I know). The software initializes at the startup of your application, so changes made in the underlying folders require a restart of your app.


## Options

 - `maxage` Browser cache max-age in milliseconds. defaults to 0
 - `hidden` Allow transfer of hidden files. defaults to false
 - `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.
 - `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/`


## Example
```js
var serve = require('koa-static-folder'),
    koa = require('koa'),
    app = koa();

app.use(serve('./public'));
app.use(serve('./assets', {maxage: 5 * 60 * 1000}));

app.use(function *(next){
    if('/' == this.path){
        this.body = 'Try GET one of the following: `/assets/style.css`,`/public/blabla.json`,`/public/style.css`';
    }
});

app.listen(8000);
console.log('Koa server listening at port 8000');
```

## License
  MIT

## Release log
0.1.6 - Added the possibility to inform max-age for caching.  
0.1.5 - Updated documentation slightly.  
0.1.4 - Updated documentation slightly.  
0.1.3 - Using procedd.cwd() instead of dirname fixing some bugs with different file locations and systems.  
0.1.2 - Removed unnecessary dependencies and fixed broken dependency.

---
_Source: https://npm.io/package/koa-static-folder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
