json-server
Advanced tools
Comparing version 0.8.9 to 0.8.10
# Change Log | ||
## [0.8.10][2016-04-18] | ||
### Added | ||
* CLI option `-ng/--no-gzip` to disable `gzip` compression | ||
## [0.8.9][2016-03-17] | ||
@@ -16,3 +22,3 @@ | ||
## Added | ||
### Added | ||
@@ -19,0 +25,0 @@ * `gzip` compression to improve performances |
{ | ||
"name": "json-server", | ||
"version": "0.8.9", | ||
"version": "0.8.10", | ||
"description": "Serves JSON files through REST routes.", | ||
@@ -5,0 +5,0 @@ "main": "./src/server/index.js", |
@@ -10,3 +10,5 @@ # JSON Server [![](https://travis-ci.org/typicode/json-server.svg)](https://travis-ci.org/typicode/json-server) [![](https://badge.fury.io/js/json-server.svg)](http://badge.fury.io/js/json-server) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/typicode/json-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
_See also [hotel](https://github.com/typicode/hotel) :hotel:, a process manager for web developers._ | ||
See also | ||
* [hotel](https://github.com/typicode/hotel) :hotel: local .dev domains for everyone and more! | ||
* [husky](https://github.com/typicode/husky) :dog: Git hooks made easy | ||
@@ -270,2 +272,3 @@ ## Example | ||
--no-cors, --nc Disable Cross-Origin Resource Sharing [boolean] | ||
--no-gzip, --ng Disable GZIP Content-Encoding [boolean] | ||
--snapshots, -S Set snapshots directory [default: "."] | ||
@@ -272,0 +275,0 @@ --delay, -d Add delay to responses (ms) |
@@ -44,2 +44,6 @@ var updateNotifier = require('update-notifier') | ||
}, | ||
'no-gzip': { | ||
alias: 'ng', | ||
description: 'Disable GZIP Content-Encoding' | ||
}, | ||
snapshots: { | ||
@@ -73,2 +77,3 @@ alias: 'S', | ||
.boolean('no-cors') | ||
.boolean('no-gzip') | ||
.help('help').alias('help', 'h') | ||
@@ -75,0 +80,0 @@ .version(pkg.version).alias('version', 'v') |
@@ -48,3 +48,4 @@ var fs = require('fs') | ||
readOnly: argv.readOnly, | ||
noCors: argv.noCors | ||
noCors: argv.noCors, | ||
noGzip: argv.noGzip | ||
} | ||
@@ -51,0 +52,0 @@ |
@@ -22,3 +22,5 @@ var fs = require('fs') | ||
// Compress all requests | ||
arr.push(compression()) | ||
if (!opts.noGzip) { | ||
arr.push(compression()) | ||
} | ||
@@ -25,0 +27,0 @@ // Logger |
@@ -0,3 +1,29 @@ | ||
// Need some fake data for the gzip test to work | ||
module.exports = function () { | ||
return { posts: [] } | ||
return { posts: [ | ||
{ | ||
id: 1, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
}, | ||
{ | ||
id: 2, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
}, | ||
{ | ||
id: 3, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
}, | ||
{ | ||
id: 4, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
}, | ||
{ | ||
id: 5, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
}, | ||
{ | ||
id: 6, | ||
content: "Oh! The garbage chute was a really wonderful idea. What an incredible smell you've discovered! Let's get out of here! Get away from there... No! wait! Will you forget it? I already tried it. It's magnetically sealed! Put that thing away! You're going to get us all killed. Absolutely, Your Worship. Look, I had everything under control until you led us down here. You know, it's not going to take them long to figure out what happened to us. It could be worst... It's worst. There's something alive in here! That's your imagination. Something just moves past my leg! Look! Did you see that? What? Help!" | ||
} | ||
]} | ||
} |
@@ -167,4 +167,3 @@ var os = require('os') | ||
if (err) { | ||
done(err) | ||
return | ||
return done(err) | ||
} else if ('access-control-allow-origin' in res.headers) { | ||
@@ -180,2 +179,54 @@ done(new Error('CORS headers were not excluded from response')) | ||
describe('db.json --no-gzip=true', function () { | ||
beforeEach(function (done) { | ||
child = cli(['fixtures/seed.js', '--no-gzip=true']) | ||
serverReady(PORT, done) | ||
}) | ||
it('should not set Content-Encoding to gzip', function (done) { | ||
var origin = 'http://example.com' | ||
request.get('/posts') | ||
.set('Origin', origin) | ||
.expect(200) | ||
.end(function (err, res) { | ||
if (err) { | ||
return done(err) | ||
} else if ('content-encoding' in res.headers) { | ||
done(new Error('Content-Encoding is set to gzip')) | ||
} else { | ||
done() | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('db.json --no-gzip=false', function () { | ||
beforeEach(function (done) { | ||
child = cli(['fixtures/seed.js', '--no-gzip=false']) | ||
serverReady(PORT, done) | ||
}) | ||
it('should set Content-Encoding to gzip', function (done) { | ||
var origin = 'http://example.com' | ||
request.get('/posts') | ||
.set('Origin', origin) | ||
.expect(200) | ||
.end(function (err, res) { | ||
if (err) { | ||
return done(err) | ||
} else if ('content-encoding' in res.headers) { | ||
done() | ||
} else { | ||
done(new Error('Content-Encoding is not set to gzip')) | ||
} | ||
}) | ||
}) | ||
}) | ||
// FIXME test fails on OS X and maybe on Windows | ||
@@ -182,0 +233,0 @@ // But manually updating db.json works... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71677
1718
373