# think_static

> Static server for ThinkKoa.

Latest version **3.0.1** (published 2020-10-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install think_static
pnpm add think_static
yarn add think_static
bun add think_static
```

## 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 | 3.0.1 |
| Published | 2020-10-28 |
| First published | 2017-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >8.0.0 |
| Dependencies | 3 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | richenlin |
| Maintainers | richenlin |

## Links

- npm: https://www.npmjs.com/package/think_static
- Homepage: https://github.com/thinkkoa/think_static
- Issues: https://github.com/thinkkoa/think_static/issues
- npm.io page: https://npm.io/package/think_static

## Dependencies (3)

- [lru-cache](https://npm.io/package/lru-cache.md) ^6.0.0
- [think_lib](https://npm.io/package/think_lib.md) ^2.x.x
- [koa-static-cache](https://npm.io/package/koa-static-cache.md) ^5.1.4

## Recent versions

- 3.0.1 (latest) — 2020-10-28
- 3.0.0 — 2020-10-28
- 2.2.0 — 2020-04-30
- 2.1.4 — 2020-04-15
- 2.1.3 — 2020-02-28
- 2.1.2 — 2019-10-22
- 2.1.1 — 2019-01-25
- 2.1.0 — 2017-12-06
- 2.0.0 — 2017-11-16
- 1.2.0 — 2017-11-15
- 1.0.10 — 2017-07-17
- 1.0.9 — 2017-06-19
- 1.0.8 — 2017-06-16
- 1.0.7 — 2017-06-14
- 1.0.6 — 2017-06-13
- … 6 more at https://npm.io/package/think_static/versions

## README

# 介绍
-----

[![npm version](https://badge.fury.io/js/think_static.svg)](https://badge.fury.io/js/think_static)

Static server Middleware for ThinkKoa.

# 安装
-----

```
npm i think_static
```

# 使用
-----

1、static中间件为thinkkoa内置中间件,无需在项目中创建引用。该中间件默认开启

2、项目中间件配置 config/middleware.js:
```
config: { //中间件配置
    ...,
    //静态资源,如果配置了Nginx代理,请设置为 static: false
    static: {
        dir: '/static', // resource path
        prefix: '', // the url prefix you wish to add, default to ''
        alias: {}, // object map of aliases. See below
        gzip: true, // when request's accept-encoding include gzip, files will compressed by gzip.
        usePrecompiledGzip: false, // try use gzip files, loaded from disk, like nginx gzip_static
        buffer: false, // store the files in memory instead of streaming from the filesystem on each request
        filter: [], // (function | array) - filter files at init dir,
        // for example - skip non build (source) files. If array set - allow only listed files
        maxAge: 3600 * 24 * 7, // cache control max age for the files, 0 by default.
        cache: true, // dynamic load file which not cached on initialization.
    }
}
```

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