Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koa-modules/serve-static
Serve static files, based on Express's serve-static.
https://github.com/koa-modules/serve-static
Last synced: about 2 months ago
JSON representation
Serve static files, based on Express's serve-static.
- Host: GitHub
- URL: https://github.com/koa-modules/serve-static
- Owner: koa-modules
- License: mit
- Created: 2015-04-02T18:09:02.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-27T08:50:21.000Z (about 9 years ago)
- Last Synced: 2024-11-08T03:23:18.520Z (2 months ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
- awesome-koa - koa-serve-static - 提供静态文件,基于 Express 的 `serve-static`。 ![](https://img.shields.io/github/stars/koa-modules/serve-static.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-serve-static.svg?style=flat-square) (仓库 / 中间件)
README
# koa-serve-static
> Serve static files for koa.
> [serve-static] wrapper for koa's middleware.[![NPM version][npm-img]][npm-url]
[![NPM Downloads][downloads-image]][npm-url]
[![Build status][travis-img]][travis-url]
[![Test coverage][coveralls-img]][coveralls-url]
[![Dependency status][david-img]][david-url]
[![License][license-img]][license-url]## Install
```sh
$ npm install --save koa-serve-static
```## Usage
### **=1.x** 100%, working with `koa-v2`
```js
const koa = require('koa');
const serveStatic = require('koa-serve-static');
const app = new Koa();app.use(serveStatic(root, options));
```### **<1.x**
```js
var koa = require('koa');
var serveStatic = require('koa-serve-static');
var app = koa();app.use(serveStatic(root, options));
```[npm-img]: https://img.shields.io/npm/v/koa-serve-static.svg?style=flat-square
[npm-url]: https://npmjs.org/package/koa-serve-static
[travis-img]: https://img.shields.io/travis/koa-modules/serve-static.svg?style=flat-square
[travis-url]: https://travis-ci.org/koa-modules/serve-static
[coveralls-img]: https://img.shields.io/coveralls/koa-modules/serve-static.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/koa-modules/serve-static?branch=master
[license-img]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
[license-url]: LICENSE
[david-img]: https://img.shields.io/david/koa-modules/serve-static.svg?style=flat-square
[david-url]: https://david-dm.org/koa-modules/serve-static
[downloads-image]: https://img.shields.io/npm/dm/koa-serve-static.svg?style=flat-square
[serve-static]: https://github.com/expressjs/serve-static