New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

koa-better-static2

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-better-static2

Static file serving middleware for koa@2

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

koa-better-static2

Node version Koajs deps Build Status David deps Coverage Status

https://nodei.co/npm/koa-better-static2.png?downloads=true&downloadRank=true&stars=true

**NOTE: This is for use with Koa 2.x.x and Nodejs 10.x.x. For Koa 1.x.x use https://github.com/ohomer/koa-better-static

This is a updated fork of koa-better-static by ohomer(https://github.com/ohomer) that uses latest Nodejs and Koajs version.

A higher performance, drop in replacement for koa-static, with a few minimal changes:

  • Doesn't use koa-send, but uses an optimized version
  • Supports If-Modified-Since header for cache/performance
  • Removal of gzip option (which checks for .gz files)
  • Removal of defer (if you want this behavior, put the middleware at the end)
  • No default index file
  • Requires node 8 or greater.

Installation

$ npm install koa-better-static2

API

const Koa = require('koa');
const serve = require('koa-better-static2');
const app = new Koa();
app.use(serve(root, opts));
  • opts options object.

Options

  • maxage Browser cache max-age in milliseconds. defaults to 0
  • hidden Allow transfer of hidden files. defaults to false
  • index Default file name, defaults to none
  • ifModifiedSinceSupport by sending a 304 (not modified) response. Defaults to true
  • format Allow trailing slashes for directories (e.g. /directory and /directory. Defaults to true

Example

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

// $ GET /package.json
app.use(serve('.'));

// $ GET /hello.txt
app.use(serve('test/fixtures'));

// or use absolute paths
app.use(serve(__dirname + '/test/fixtures'));

app.listen(3000);

console.log('listening on port 3000');

License

MIT

Keywords

koa

FAQs

Package last updated on 06 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts