diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 0662e50..0000000 --- a/Readme.md +++ /dev/null @@ -1,48 +0,0 @@ - -# koa-conditional-get [![Build Status](https://travis-ci.org/koajs/conditional-get.png)](https://travis-ci.org/koajs/conditional-get) - - Conditional GET support for koa. - -## Installation - -```js -$ npm install koa-conditional-get -``` - -## Example - -```js -const conditional = require('koa-conditional-get'); -const etag = require('koa-etag'); -const Koa = require('koa'); -const app = new Koa(); - -// use it upstream from etag so -// that they are present - -app.use(conditional()); - -// add etags - -app.use(etag()); - -// respond - -app.use(async function(ctx, next){ - await next(); - - ctx.body = { - name: 'tobi', - species: 'ferret', - age: 2 - }; -}) - -app.listen(3000); - -console.log('listening on port 3000'); -``` - -## License - - MIT diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 5f39213..0000000 --- a/test/index.js +++ /dev/null @@ -1,57 +0,0 @@ - -'use strict'; - -const request = require('supertest'); -const calculate = require('etag'); -const conditional = require('..'); -const etag = require('koa-etag'); -const Koa = require('koa'); -const fs = require('fs'); - -var body = { - name: 'tobi', - species: 'ferret', - age: 2 -}; - -describe('conditional()', function(){ - describe('when cache is fresh', function(){ - it('should respond with 304', function(done){ - const app = new Koa(); - - app.use(conditional()); - app.use(etag()); - - app.use((ctx, next) => { - return next().then(() => { - ctx.body = body; - }); - }); - - request(app.listen()) - .get('/') - .set('If-None-Match', calculate(JSON.stringify(body))) - .expect(304, done); - }) - }) - - describe('when cache is stale', function(){ - it('should do nothing', function(done){ - const app = new Koa(); - - app.use(conditional()); - app.use(etag()); - - app.use((ctx, next) => { - return next().then(() => { - ctx.body = body; - }); - }); - - request(app.listen()) - .get('/') - .set('If-None-Match', 'tobi') - .expect(200, done); - }) - }) -})