
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
koa-better-static2
Advanced tools
**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:
If-Modified-Since header for cache/performancegzip option (which checks for .gz files)defer (if you want this behavior, put the middleware at the end)index file$ npm install koa-better-static2
const Koa = require('koa');
const serve = require('koa-better-static2');
const app = new Koa();
app.use(serve(root, opts));
opts options object.maxage Browser cache max-age in milliseconds. defaults to 0hidden Allow transfer of hidden files. defaults to falseindex Default file name, defaults to noneifModifiedSinceSupport by sending a 304 (not modified) response. Defaults to trueformat Allow trailing slashes for directories (e.g. /directory and /directory. Defaults to trueconst 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');
MIT
FAQs
Static file serving middleware for koa@2
We found that koa-better-static2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.