Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-static

Package Overview
Dependencies
Maintainers
10
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-static - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

6

History.md
3.0.0 / 2016-03-24
==================
* support koa 2.x
* travis: test node@4+
2.0.0 / 2016-01-07

@@ -3,0 +9,0 @@ ==================

28

index.js

@@ -8,5 +8,5 @@

const debug = require('debug')('koa-static');
const resolve = require('path').resolve;
const assert = require('assert');
const debug = require('debug')('koa-static');
const send = require('koa-send');

@@ -40,19 +40,23 @@

if (!opts.defer) {
return function *serve(next){
if (this.method == 'HEAD' || this.method == 'GET') {
if (yield send(this, this.path, opts)) return;
return function serve(ctx, next){
if (ctx.method == 'HEAD' || ctx.method == 'GET') {
return send(ctx, ctx.path, opts).then(done => {
if (!done) {
return next();
}
});
}
yield* next;
return next();
};
}
return function *serve(next){
yield* next;
return function serve(ctx, next){
return next().then(() => {
if (ctx.method != 'HEAD' && ctx.method != 'GET') return;
// response is already handled
if (ctx.body != null || ctx.status != 404) return;
if (this.method != 'HEAD' && this.method != 'GET') return;
// response is already handled
if (this.body != null || this.status != 404) return;
yield send(this, this.path, opts);
return send(ctx, ctx.path, opts);
});
};
}

@@ -5,3 +5,3 @@ {

"repository": "koajs/static",
"version": "2.0.0",
"version": "3.0.0",
"keywords": [

@@ -18,4 +18,4 @@ "koa",

"devDependencies": {
"istanbul-harmony": "0",
"koa": "1",
"istanbul": "0",
"koa": "2",
"mocha": "2",

@@ -27,3 +27,3 @@ "supertest": "1"

"debug": "*",
"koa-send": "~3.1.0"
"koa-send": "^3.2.0"
},

@@ -30,0 +30,0 @@ "scripts": {

@@ -10,5 +10,4 @@ # koa-static

Koa static file serving middleware, wrapper for [`koa-send`](https://github.com/koajs/send).
Static file serving middleware.
## Installation

@@ -36,3 +35,4 @@

- `index` Default file name, defaults to 'index.html'
- `defer` If true, serves after `yield next`, allowing any downstream middleware to respond first.
- `defer` If true, serves after `return next()`, allowing any downstream middleware to respond first.
- `gzip` Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.

@@ -60,2 +60,8 @@ ## Example

### See also
- [koajs/conditional-get](https://github.com/koajs/conditional-get) Conditional GET support for koa
- [koajs/compress](https://github.com/koajs/compress) Compress middleware for koa
- [koajs/mount](https://github.com/koajs/mount) Mount `koa-static` to a specific path
## License

@@ -62,0 +68,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc