@loopback/http-server 2.2.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/http-server.d.ts +8 -2
- package/dist/http-server.js +17 -0
- package/dist/http-server.js.map +1 -1
- package/package.json +9 -9
- package/src/http-server.ts +43 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.3.3](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@2.3.2...@loopback/http-server@2.3.3) (2020-12-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/http-server
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.3.2](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@2.3.1...@loopback/http-server@2.3.2) (2020-11-18)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @loopback/http-server
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.3.1](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@2.3.0...@loopback/http-server@2.3.1) (2020-11-05)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @loopback/http-server
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [2.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@2.2.2...@loopback/http-server@2.3.0) (2020-10-07)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **http-server:** configure http.Server and Server properties ([42ad4b8](https://github.com/strongloop/loopback-next/commit/42ad4b887616879241337af1817fe30690641188))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## [2.2.2](https://github.com/strongloop/loopback-next/compare/@loopback/http-server@2.2.1...@loopback/http-server@2.2.2) (2020-09-17)
|
|
7
42
|
|
|
8
43
|
**Note:** Version bump only for package @loopback/http-server
|
package/dist/http-server.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import http, { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
import http, { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import { AddressInfo, ListenOptions } from 'net';
|
|
5
5
|
/**
|
|
6
6
|
* Request listener function for http/https requests
|
|
7
7
|
*/
|
|
8
8
|
export declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
9
|
+
/**
|
|
10
|
+
* The following are for configuring properties which are directly set on
|
|
11
|
+
* https://nodejs.org/api/http.html#http_class_http_server and
|
|
12
|
+
* https://nodejs.org/api/net.html#net_class_net_server
|
|
13
|
+
*/
|
|
14
|
+
export declare type HttpServerProperties = Pick<Server, 'keepAliveTimeout' | 'headersTimeout' | 'maxConnections' | 'maxHeadersCount' | 'timeout'>;
|
|
9
15
|
/**
|
|
10
16
|
* Base options that are common to http and https servers
|
|
11
17
|
*/
|
|
12
|
-
export interface BaseHttpOptions extends ListenOptions {
|
|
18
|
+
export interface BaseHttpOptions extends ListenOptions, Partial<HttpServerProperties> {
|
|
13
19
|
/**
|
|
14
20
|
* The `gracePeriodForClose` property controls how to stop the server
|
|
15
21
|
* gracefully. Its value is the number of milliseconds to wait before
|
package/dist/http-server.js
CHANGED
|
@@ -46,6 +46,23 @@ class HttpServer {
|
|
|
46
46
|
else {
|
|
47
47
|
this.server = http_1.default.createServer(this.requestListener);
|
|
48
48
|
}
|
|
49
|
+
// Apply server properties
|
|
50
|
+
const { keepAliveTimeout, headersTimeout, maxConnections, maxHeadersCount, timeout, } = this.serverOptions;
|
|
51
|
+
if (keepAliveTimeout) {
|
|
52
|
+
this.server.keepAliveTimeout = keepAliveTimeout;
|
|
53
|
+
}
|
|
54
|
+
if (headersTimeout) {
|
|
55
|
+
this.server.headersTimeout = headersTimeout;
|
|
56
|
+
}
|
|
57
|
+
if (maxConnections) {
|
|
58
|
+
this.server.maxConnections = maxConnections;
|
|
59
|
+
}
|
|
60
|
+
if (maxHeadersCount) {
|
|
61
|
+
this.server.maxHeadersCount = maxHeadersCount;
|
|
62
|
+
}
|
|
63
|
+
if (timeout) {
|
|
64
|
+
this.server.timeout = timeout;
|
|
65
|
+
}
|
|
49
66
|
// Set up graceful stop for http server
|
|
50
67
|
if (typeof this.serverOptions.gracePeriodForClose === 'number') {
|
|
51
68
|
debug('Http server gracePeriodForClose %d', this.serverOptions.gracePeriodForClose);
|
package/dist/http-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,qCAAqC;AACrC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,4DAA4B;AAC5B,0DAAiC;AACjC,mCAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,qCAAqC;AACrC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,4DAA4B;AAC5B,0DAAiC;AACjC,mCAA4B;AAC5B,wDAAmE;AACnE,0DAA0B;AAE1B,oDAAoB;AACpB,kEAAkC;AAClC,MAAM,KAAK,GAAG,eAAY,CAAC,sBAAsB,CAAC,CAAC;AAuEnD;;GAEG;AACH,MAAa,UAAU;IASrB;;;OAGG;IACH,YACE,eAAgC,EAChC,aAAiC;;QAd3B,eAAU,GAAG,KAAK,CAAC;QAgBzB,KAAK,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC;QAC5C,IAAI,CAAC,eA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,GAAG,WAAW,CAAC;SACpB;QACD,OAAO,GAAG,IAAI,CAAC,SAAS,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,CAAC;CACF;AAxKD,gCAwKC;AAED;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,wBAAwB;IACxB,IAAI,OAAO,EAAE,EAAE;QACb,MAAM,KAAK,GAAG,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QACjD,gBAAM,CACJ,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EACtC,cAAc,OAAO,0BAA0B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACpE,CAAC;KACH;AACH,CAAC;AAED;;GAEG;AACH,SAAS,OAAO;IACd,OAAO,YAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/http-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "A wrapper for creating HTTP/HTTPS servers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": "^10.16 || 12 || 14"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "lb-tsc",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"debug": "^4.
|
|
24
|
+
"debug": "^4.3.1",
|
|
25
25
|
"stoppable": "^1.1.0",
|
|
26
|
-
"tslib": "^2.0.
|
|
26
|
+
"tslib": "^2.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@loopback/build": "^6.2.
|
|
30
|
-
"@loopback/core": "^2.
|
|
31
|
-
"@loopback/eslint-config": "^10.0.
|
|
32
|
-
"@loopback/testlab": "^3.2.
|
|
29
|
+
"@loopback/build": "^6.2.8",
|
|
30
|
+
"@loopback/core": "^2.13.1",
|
|
31
|
+
"@loopback/eslint-config": "^10.0.4",
|
|
32
|
+
"@loopback/testlab": "^3.2.10",
|
|
33
33
|
"@types/debug": "^4.1.5",
|
|
34
34
|
"@types/node": "^10.17.35",
|
|
35
35
|
"@types/stoppable": "^1.1.0"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
46
46
|
"directory": "packages/http-server"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "44fc7765fa322c716e8f2914b3831748041ebd8c"
|
|
49
49
|
}
|
package/src/http-server.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import assert from 'assert';
|
|
7
7
|
import debugFactory from 'debug';
|
|
8
8
|
import {once} from 'events';
|
|
9
|
-
import http, {IncomingMessage, ServerResponse} from 'http';
|
|
9
|
+
import http, {IncomingMessage, Server, ServerResponse} from 'http';
|
|
10
10
|
import https from 'https';
|
|
11
11
|
import {AddressInfo, ListenOptions} from 'net';
|
|
12
12
|
import os from 'os';
|
|
@@ -21,10 +21,26 @@ export type RequestListener = (
|
|
|
21
21
|
res: ServerResponse,
|
|
22
22
|
) => void;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The following are for configuring properties which are directly set on
|
|
26
|
+
* https://nodejs.org/api/http.html#http_class_http_server and
|
|
27
|
+
* https://nodejs.org/api/net.html#net_class_net_server
|
|
28
|
+
*/
|
|
29
|
+
export type HttpServerProperties = Pick<
|
|
30
|
+
Server,
|
|
31
|
+
| 'keepAliveTimeout'
|
|
32
|
+
| 'headersTimeout'
|
|
33
|
+
| 'maxConnections'
|
|
34
|
+
| 'maxHeadersCount'
|
|
35
|
+
| 'timeout'
|
|
36
|
+
>;
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
39
|
* Base options that are common to http and https servers
|
|
26
40
|
*/
|
|
27
|
-
export interface BaseHttpOptions
|
|
41
|
+
export interface BaseHttpOptions
|
|
42
|
+
extends ListenOptions,
|
|
43
|
+
Partial<HttpServerProperties> {
|
|
28
44
|
/**
|
|
29
45
|
* The `gracePeriodForClose` property controls how to stop the server
|
|
30
46
|
* gracefully. Its value is the number of milliseconds to wait before
|
|
@@ -109,6 +125,31 @@ export class HttpServer {
|
|
|
109
125
|
} else {
|
|
110
126
|
this.server = http.createServer(this.requestListener);
|
|
111
127
|
}
|
|
128
|
+
|
|
129
|
+
// Apply server properties
|
|
130
|
+
const {
|
|
131
|
+
keepAliveTimeout,
|
|
132
|
+
headersTimeout,
|
|
133
|
+
maxConnections,
|
|
134
|
+
maxHeadersCount,
|
|
135
|
+
timeout,
|
|
136
|
+
} = this.serverOptions;
|
|
137
|
+
if (keepAliveTimeout) {
|
|
138
|
+
this.server.keepAliveTimeout = keepAliveTimeout;
|
|
139
|
+
}
|
|
140
|
+
if (headersTimeout) {
|
|
141
|
+
this.server.headersTimeout = headersTimeout;
|
|
142
|
+
}
|
|
143
|
+
if (maxConnections) {
|
|
144
|
+
this.server.maxConnections = maxConnections;
|
|
145
|
+
}
|
|
146
|
+
if (maxHeadersCount) {
|
|
147
|
+
this.server.maxHeadersCount = maxHeadersCount;
|
|
148
|
+
}
|
|
149
|
+
if (timeout) {
|
|
150
|
+
this.server.timeout = timeout;
|
|
151
|
+
}
|
|
152
|
+
|
|
112
153
|
// Set up graceful stop for http server
|
|
113
154
|
if (typeof this.serverOptions.gracePeriodForClose === 'number') {
|
|
114
155
|
debug(
|