remove app.jsonSpaces setting. Closes #202

This commit is contained in:
TJ Holowaychuk 2014-01-31 18:39:47 -08:00
parent ea5757ff57
commit aa08845c70
4 changed files with 4 additions and 34 deletions

View file

@ -79,7 +79,6 @@ app.listen(3000);
- `app.env` defaulting to the __NODE_ENV__ or "development"
- `app.proxy` when true proxy header fields will be trusted
- `app.subdomainOffset` offset of `.subdomains` to ignore [2]
- `app.jsonSpaces` default JSON response spaces [2]
- `app.outputErrors` output err.stack to stderr [false in "test" environment]
## app.listen(...)

View file

@ -11,7 +11,7 @@
Response header object.
### res.socket
Request socket.
### res.status
@ -130,15 +130,6 @@ so you can make a correction.
The Content-Type is defaulted to application/json.
#### Notes
To alter the JSON response formatting use the `app.jsonSpaces`
setting, for example to compress JSON responses set:
```js
app.jsonSpaces = 0;
```
### res.get(field)
Get a response header field value with case-insensitive `field`.
@ -257,7 +248,7 @@ this.response.etag = crypto.createHash('md5').update(this.body).digest('hex');
Append `val` to header `field`.
### res.vary(field)
Vary on `field`.

View file

@ -40,7 +40,6 @@ function Application() {
this.outputErrors = 'test' != this.env;
this.subdomainOffset = 2;
this.poweredBy = true;
this.jsonSpaces = 2;
this.middleware = [];
this.context = Object.create(context);
this.request = Object.create(request);
@ -194,7 +193,7 @@ function *respond(next){
}
// body: json
body = JSON.stringify(body, null, this.app.jsonSpaces);
body = JSON.stringify(body);
this.length = Buffer.byteLength(body);
if (head) return res.end();
res.end(body);

View file

@ -409,26 +409,7 @@ describe('app.respond', function(){
request(server)
.get('/')
.expect('Content-Type', 'application/json')
.expect('{\n "hello": "world"\n}', done);
})
describe('when app.jsonSpaces is altered', function(){
it('should reflect in the formatting', function(done){
var app = koa();
app.jsonSpaces = 0;
app.use(function *(){
this.body = { hello: 'world' };
});
var server = app.listen();
request(server)
.get('/')
.expect('Content-Type', 'application/json')
.expect('{"hello":"world"}', done);
})
.expect('{"hello":"world"}', done);
})
})