JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 323
  • Score
    100M100P100Q90776F
  • License MIT

Small, simple and correct serving of files, using [koa-send][] - nothing more.

Package Exports

  • koa-better-serve

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koa-better-serve) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

koa-better-serve npmjs.com The MIT License npm downloads

Small, simple and correct serving of files, using koa-send - nothing more.

code climate standard code style travis build status coverage status dependency status

Install

npm i koa-better-serve --save

Usage

For more use-cases see the tests

const koaBetterServe = require('koa-better-serve')

koaBetterServe

Serving dir of files and folders, when request url (ctx.url) match to pathname. All behind the scenes is just using koa-send. Hint: use koa-convert to use it for koa v1.

Params

  • <dir> {String|Buffer}: folder to serve
  • [pathname] {String|RegExp}: path to match, can be regex
  • [opts] {Object}: optional, passed directly to koa-send
  • returns {Function}: plugin which returns Promise when called

Example

const serve = require('koa-better-serve')
const Koa = require('koa')
const app = new Koa()

app.use(serve('./uploads/images', '/images'))
app.listen(4290)

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github