Comparing version 0.2.1 to 0.2.2
@@ -511,2 +511,4 @@ | ||
proxy?: boolean | ||
[x: string]: any | ||
} | ||
@@ -513,0 +515,0 @@ |
@@ -6,12 +6,12 @@ "use strict"; | ||
const timers_1 = require("timers"); | ||
class Server { | ||
class default_1 { | ||
/** | ||
* Initialize a Server instance | ||
* | ||
* @param native HTTP(S) server instance | ||
* @param server HTTP(S) server instance | ||
* @param options | ||
*/ | ||
constructor(native, options = {}) { | ||
this.native = native; | ||
constructor(server, options = {}) { | ||
this._options = options; | ||
this.native = server; | ||
} | ||
@@ -25,5 +25,3 @@ /** | ||
on(event, fn) { | ||
if (event === 'request') | ||
fn = this._wrap(fn); | ||
this.native.on(event, fn); | ||
this.native.on(event, this._wrap(event, fn)); | ||
return this; | ||
@@ -57,12 +55,19 @@ } | ||
* | ||
* @param fn event listener | ||
* @param event | ||
* @param fn listener | ||
* @private | ||
*/ | ||
_wrap(fn) { | ||
_wrap(event, fn) { | ||
var opts = this._options; | ||
return (req, res) => { | ||
timers_1.setImmediate(fn, new request_1.default(req, opts), new response_1.default(res, opts)); | ||
}; | ||
switch (event) { | ||
case 'request': | ||
case 'checkContinue': | ||
case 'checkExpectation': | ||
return (req, res) => { | ||
timers_1.setImmediate(fn, new request_1.default(req, opts), new response_1.default(res, opts)); | ||
}; | ||
} | ||
return () => { timers_1.setImmediate(fn, ...arguments); }; | ||
} | ||
} | ||
exports.default = Server; | ||
exports.default = default_1; |
{ | ||
"name": "aldo-http", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Enhanced HTTP createServer module for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -28,3 +28,3 @@ | ||
### HTTP server | ||
### HTTP | ||
```js | ||
@@ -56,3 +56,3 @@ const { createServer } = require('aldo-http') | ||
### HTTPS server | ||
### HTTPS | ||
```js | ||
@@ -85,2 +85,3 @@ const { readFileSync } = require('fs') | ||
``` | ||
### Trust proxy | ||
@@ -159,2 +160,4 @@ To enable parsing `X-Forwarded-*` request headers, the `proxy` flag can be set to `true` | ||
readonly writable: boolean; | ||
readonly headersSent: boolean; | ||
readonly headers: http.OutgoingHttpHeaders; | ||
@@ -161,0 +164,0 @@ |
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
56229
1782
187