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

quinn-respond

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quinn-respond - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

55

lib/respond.js

@@ -37,3 +37,23 @@ 'use strict';

this._headers = c;
this.body(body);
}
QuinnResponse.prototype.header =
function header(key, value, clobber) {
this._headers.set(key, value, clobber);
return this;
};
QuinnResponse.prototype.status =
function status(code) {
this.statusCode = code;
return this;
};
QuinnResponse.prototype.body =
function body(body) {
if (body === undefined) {
return this;
}
if (typeof body === 'string') {

@@ -47,17 +67,28 @@ body = new Buffer(body, 'utf8');

this.body = bodyToStream(body);
}
body = bodyToStream(body);
QuinnResponse.prototype.header =
function header(key, value, clobber) {
this._headers.set(key, value, clobber);
if (this._body === undefined) {
this._body = body;
} else {
body.pipe(this._body);
}
return this;
};
QuinnResponse.prototype.status =
function status(code) {
this.statusCode = code;
return this;
QuinnResponse.prototype.text = function(body) {
return this.body(body)
.header('Content-Type', 'text/plain; charset=utf-8');
};
QuinnResponse.prototype.html = function(body) {
return this.body(body)
.header('Content-Type', 'text/html; charset=utf-8');
};
QuinnResponse.prototype.json = function(data, visitor, indent) {
return this.body(JSON.stringify(data, visitor, indent))
.header('Content-Type', 'application/json; charset=utf-8');
};
QuinnResponse.prototype._forwardMeta =

@@ -82,3 +113,3 @@ function _forwardMeta(dest) {

return this.body.pipe(target);
return this._body.pipe(target);
};

@@ -126,5 +157,3 @@

function json(data, visitor, indent) {
var body = JSON.stringify(data, visitor, indent);
return respond({ body: body })
.header('Content-Type', 'application/json; charset=utf-8');
return respond().json(data, visitor, indent);
}

@@ -131,0 +160,0 @@ respond.json = json;

{
"name": "quinn-respond",
"version": "3.0.0",
"version": "3.1.0",
"description": "Response generation for quinn",

@@ -5,0 +5,0 @@ "main": "lib/respond.js",

@@ -16,3 +16,3 @@ /*global describe, it */

server.makeRequest(function() {
return respond.text('ok')
return respond().text('ok')
.status(201);

@@ -33,3 +33,3 @@ }).then(function(res) {

// http://stackoverflow.com/questions/9864662/how-to-get-the-string-length-in-bytes-in-nodejs
return respond.html('äáöü')
return respond().html('äáöü')
.status(201);

@@ -49,3 +49,3 @@ }).then(function(res) {

server.makeRequest(function() {
return respond.json({ x: 2 });
return respond().json({ x: 2 });
}).then(function(res) {

@@ -61,3 +61,3 @@ assert.equal('{"x":2}', res.body);

server.makeRequest(function() {
return respond.json({ x: 2 }, null, 2);
return respond().json({ x: 2 }, null, 2);
}).then(function(res) {

@@ -64,0 +64,0 @@ assert.equal('{\n "x": 2\n}', res.body);

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