# koa-static-alter

> Add two functions based on koa-static

Latest version **1.0.0** (published 2019-06-17) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-06-17 |
| First published | 2019-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | aaron ton |
| Maintainers | aaron_ton |
| Keywords | koa, static, middleware, file, sendFile |

## Links

- npm: https://www.npmjs.com/package/koa-static-alter
- npm.io page: https://npm.io/package/koa-static-alter

## Dependencies (1)

- [koa-send](https://npm.io/package/koa-send.md) ^5.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-06-17

## README

> `npm install --save koa-static-alter`

Add two functions based on ```koa-static```

## rootPath
before
```javascript
// request /static/1.jpg
app.use(staticServer(path.join(__dirname, "./static")));
// response 404
```
after
```javascript
// request /static/1.jpg
app.use(staticServer(path.join(__dirname, "./static", {
    rootPath: "/static"
})));
// response 200 ok
```

## replace

before
```javascript
// request /replace/1.jpg
app.use(staticServer(path.join(__dirname, "./static")));
// response 404
```

after
```javascript
// request /replace/1.jpg
app.use(staticServer(path.join(__dirname, "./static", {
    replace: "/replace"
})));
// response ok
```


- array
```javascript
// request /replace/1.jpg
app.use(staticServer(path.join(__dirname, "./static", { 
    replace: ["/replace", ""] // arr[1] customize default ""
    // replace: ["/replace"]
})));
// response ok
```

```javascript
// request /replace/1.jpg
app.use(staticServer(path.join(__dirname, "./static", { 
    replace: [/\/replace/, ""] // arr[1] customize default ""
})));
// response ok
```

- function
```javascript
// request /replace/1.jpg
app.use(staticServer(path.join(__dirname, "./static", { 
    replace: (path) => {
        return path.replace(/\/replace/, "");
    }
})));
// response ok
```

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