Comparing version 0.2.0 to 0.2.1
@@ -61,2 +61,3 @@ import { Readable } from 'stream'; | ||
private _bodyUsed; | ||
private _bodyBuffered; | ||
private _headers; | ||
@@ -75,2 +76,3 @@ private _trailers; | ||
readonly bodyUsed: boolean; | ||
readonly bodyBuffered: boolean; | ||
type: string | undefined; | ||
@@ -77,0 +79,0 @@ length: number | undefined; |
"use strict"; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var stream_1 = require("stream"); | ||
@@ -34,3 +40,3 @@ var url_1 = require("url"); | ||
function join(a, b) { | ||
if (a == null) { | ||
if (a === undefined) { | ||
return b; | ||
@@ -63,3 +69,2 @@ } | ||
}(make_error_cause_1.BaseError)); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = HttpError; | ||
@@ -170,2 +175,3 @@ /** | ||
this._bodyUsed = true; | ||
this._bodyBuffered = true; | ||
this._started = false; | ||
@@ -245,5 +251,6 @@ this._finished = false; | ||
set: function (body) { | ||
this._body = body; | ||
this._bodyUsed = false; | ||
if (body == null) { | ||
if (body === undefined || body === null) { | ||
this._body = undefined; | ||
this._bodyBuffered = true; | ||
this.headers.delete('Content-Type'); | ||
@@ -259,2 +266,4 @@ this.headers.delete('Content-Length'); | ||
} | ||
this._body = body; | ||
this._bodyBuffered = true; | ||
this.length = Buffer.byteLength(body); | ||
@@ -267,2 +276,4 @@ return; | ||
} | ||
this._body = body; | ||
this._bodyBuffered = true; | ||
this.length = body.length; | ||
@@ -275,2 +286,4 @@ return; | ||
} | ||
this._body = body; | ||
this._bodyBuffered = false; | ||
this.length = undefined; | ||
@@ -280,5 +293,6 @@ return; | ||
if (isBasicObject(body)) { | ||
this.type = 'application/json'; | ||
var str = JSON.stringify(body); | ||
this._body = str; | ||
this.type = 'application/json'; | ||
this._bodyBuffered = true; | ||
this.length = Buffer.byteLength(str); | ||
@@ -299,6 +313,13 @@ return; | ||
}); | ||
Object.defineProperty(Common.prototype, "bodyBuffered", { | ||
get: function () { | ||
return this._bodyBuffered; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Common.prototype, "type", { | ||
get: function () { | ||
var header = this.headers.get('Content-Type'); | ||
return header == null ? undefined : type(header); | ||
return header === undefined ? undefined : type(header); | ||
}, | ||
@@ -314,3 +335,3 @@ set: function (type) { | ||
var len = this.headers.get('Content-Length'); | ||
return len == null ? undefined : Number(len); | ||
return len === undefined ? undefined : Number(len); | ||
}, | ||
@@ -329,6 +350,3 @@ set: function (length) { | ||
var body; | ||
if (this._body == null) { | ||
body = Promise.resolve(undefined); | ||
} | ||
else if (Buffer.isBuffer(this._body)) { | ||
if (this._body === undefined || Buffer.isBuffer(this._body)) { | ||
body = Promise.resolve(this._body); | ||
@@ -374,3 +392,3 @@ } | ||
var body; | ||
if (this._body == null) { | ||
if (this._body === undefined) { | ||
body = new stream_1.Readable({ read: function () { this.push(null); } }); | ||
@@ -377,0 +395,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var index_1 = require("./index"); | ||
@@ -3,0 +4,0 @@ describe('servie', function () { |
{ | ||
"name": "servie", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Standard HTTP interfaces", | ||
@@ -44,7 +44,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"jest": "^18.1.0", | ||
"jest": "^19.0.0", | ||
"rimraf": "^2.5.4", | ||
"tslint": "^4.3.1", | ||
"tslint-config-standard": "^3.0.0", | ||
"typescript": "^2.1.5", | ||
"tslint-config-standard": "^4.0.0", | ||
"typescript": "^2.2.1", | ||
"typings": "^2.1.0" | ||
@@ -51,0 +51,0 @@ }, |
@@ -24,2 +24,8 @@ # ![Servie](https://cdn.rawgit.com/blakeembrey/node-servie/master/logo.svg) | ||
* [`get-body`](https://github.com/blakeembrey/node-get-body) General body parser for forms, JSON and text | ||
* [`servie-cors`](https://github.com/blakeembrey/node-servie-cors) CORS middleware for Servie | ||
* [`servie-route`](https://github.com/blakeembrey/node-servie-route) Routing middleware for Servie | ||
* [`servie-mount`](https://github.com/blakeembrey/node-servie-mount) Mount Servie middleware on a path prefix | ||
* [`servie-compat-http`](https://github.com/blakeembrey/node-servie-compat-http) Mimic node.js HTTP using Servie | ||
* [`servie-redirect`](https://github.com/blakeembrey/node-servie-redirect) Create response objects for redirection | ||
* [`servie-cookie-store`](https://github.com/blakeembrey/node-servie-cookie-store) API for managing client-side cookies | ||
@@ -173,4 +179,5 @@ ### `Common` | ||
2. Listen to the `abort` event on `Request` to destroy the HTTP request | ||
3. Set `started === true` and `finished === true` on `Request` and `Response`, as appropriate | ||
4. Set `bytesTransferred` on `Request` and `Response` when monitoring HTTP transfer progress | ||
3. Emit the `response` event on `Request` when handling the response | ||
4. Set `started === true` and `finished === true` on `Request` and `Response`, as appropriate | ||
5. Set `bytesTransferred` on `Request` and `Response` when monitoring HTTP transfer progress | ||
@@ -187,3 +194,3 @@ ## JavaScript | ||
MIT | ||
Apache 2.0 | ||
@@ -190,0 +197,0 @@ [npm-image]: https://img.shields.io/npm/v/servie.svg?style=flat |
{ | ||
"globalDependencies": { | ||
"node": "registry:env/node#4.0.0+20170115054122" | ||
"node": "registry:env/node#6.0.0+20170213133316" | ||
}, | ||
@@ -5,0 +5,0 @@ "globalDevDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
74726
765
202