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

quinn

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quinn - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

CHANGELOG.md

27

express.js
'use strict';
const quinn = require('./');
const runApplication = quinn.runApplication;
const respond = quinn.respond;
function createApp(handler) {
return function(req, res, next) {
function forwardError(err) {
setImmediate(function() { next(err); });
}
function callNext(result) {
if (result === undefined) setImmediate(next);
return result;
}
return runApplication(handler, req, res)
.then(callNext)
.then(null, forwardError);
};
}
module.exports = createApp;
createApp['default'] = createApp;
createApp.createApp = createApp;
createApp.respond = respond;
createApp.runApplication = runApplication;
module.exports = require('./lib/express');
{
"name": "quinn",
"version": "3.2.1",
"version": "3.3.0",
"description": "A web framework designed for things to come.",
"main": "dist/quinn.js",
"license": "BSD-3-Clause",
"main": "lib/quinn.js",
"homepage": "https://github.com/groupon/quinn",
"repository": {
"type": "git",
"url": "https://github.com/groupon/quinn"
},
"bugs": {
"url": "https://github.com/groupon/quinn/issues"
},
"scripts": {
"test": "jshint *.js && mocha --harmony"
"pretest": "eslint lib test",
"test": "mocha",
"posttest": "nlm verify"
},
"author": {
"name": "Jan Krems",
"email": "jan.krems@gmail.com>"
"nlm": {
"license": {
"files": [
"lib"
]
}
},
"license": "MIT",
"dependencies": {

@@ -18,22 +31,28 @@ "caseless": "^0.10.0"

"devDependencies": {
"babel": "^5.1.10",
"assertive": "^2.1.0",
"eslint": "^5.1.0",
"eslint-config-groupon": "^7.2.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-mocha": "^5.1.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-prettier": "^2.6.2",
"express": "^4.12.3",
"gofer": "^2.3.6",
"jshint": "^2.7.0",
"mocha": "^2.2.4",
"mocha": "^3.1.2",
"nlm": "^3.6.1",
"prettier": "^1.6.1",
"response": "^0.14.0",
"wegweiser": "^3.2.1"
},
"directories": {
"example": "examples",
"test": "test"
"author": {
"name": "Groupon",
"email": "opensource@groupon.com"
},
"repository": {
"type": "git",
"url": "git://github.com/quinnjs/quinn.git"
},
"bugs": {
"url": "https://github.com/quinnjs/quinn/issues"
},
"homepage": "https://github.com/quinnjs/quinn"
"files": [
"*.js",
"lib"
],
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}

@@ -37,2 +37,23 @@ # Quinn

#### `respond`
The `respond` function is the primary means to create `VirtualResponse` instances.
It takes one of three possible values:
* An existing `VirtualResponse` instance that will be returned unchanged.
This ensures that calling `respond` multiple times is idempotent.
* A response body (see below).
* An object with any combination of numeric `statusCode`,
`headers` object, and/or a `body` property.
The `body` can be one of the following:
* A buffer or `Uint8Array`.
* A string.
* A readable stream.
* An empty body can be expressed by passing `null`.
* A function that takes a request and a response and returns one of the previous types.
This variant is called a "lazy body" and can be used to delay serialization
or returns bodies that depend on the incoming request as with JSONP responses.
#### `VirtualResponse`

@@ -57,4 +78,7 @@

Quinn itself only cares that it has a `pipe` method
which is used to forward the data to a [`ServerResponse`](https://iojs.org/api/http.html#http_class_http_serverresponse).
A `VirtualResponse` can either be piped to a target stream
or forwarded using `response.forwardTo(req, res)`.
Lazy bodies are only supported when using `forwardTo`.
When using `forwardTo`, it will return a promise
that resolves once the response has been successfully written.

@@ -61,0 +85,0 @@ ## Combining Quinn

'use strict';
const Stream = require('stream');
const httpify = require('caseless').httpify;
class VirtualResponse extends Stream.PassThrough {
constructor(props) {
super();
this.statusCode = props.statusCode || 200;
httpify(this, props.headers);
if ('body' in props) this.body(props.body);
}
status(code) {
this.statusCode = code;
return this;
}
header(name, value) {
this.setHeader(name, value);
return this;
}
body(body) {
if (typeof body === 'string') body = new Buffer(body);
if (body instanceof Buffer) {
this.body = body;
this.header('Content-Length', body.length);
this.end(body);
} else {
throw new TypeError('Body has to be a string or a Buffer');
}
return this;
}
pipe(res, options) {
res.statusCode = this.statusCode;
if (typeof res.setHeader === 'function') {
const headers = this.headers;
const headerNames = Object.keys(headers);
for (let i = 0; i < headerNames.length; ++i) {
const name = headerNames[i];
res.setHeader(name, headers[name]);
}
}
return super.pipe(res, options);
}
}
function respond(props) {
return new VirtualResponse(props || {});
}
function json(obj, visitor, indent) {
return respond({
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify(obj, visitor, indent)
});
}
module.exports = respond;
module.exports['default'] = respond;
module.exports.respond = respond;
module.exports.json = json;
module.exports = require('./lib/respond');

Sorry, the diff of this file is not supported yet

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