@travetto/web-http 7.0.0-rc.0 → 7.0.0-rc.2
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/README.md +4 -4
- package/package.json +2 -2
- package/src/config.ts +2 -2
- package/src/http.ts +5 -5
package/README.md
CHANGED
|
@@ -132,11 +132,11 @@ export class WebHttpConfig {
|
|
|
132
132
|
this.bindAddress ||= await NetUtil.getLocalAddress();
|
|
133
133
|
|
|
134
134
|
if (!this.tls) {
|
|
135
|
-
// Clear out keys if
|
|
135
|
+
// Clear out keys if tls is not set
|
|
136
136
|
this.tlsKeys = undefined;
|
|
137
137
|
} else if (!this.tlsKeys) {
|
|
138
138
|
if (Runtime.production) {
|
|
139
|
-
throw new AppError('Default
|
|
139
|
+
throw new AppError('Default tls keys are only valid for development use, please specify a config value at web.tls.keys');
|
|
140
140
|
}
|
|
141
141
|
this.tlsKeys = await WebTlsUtil.generateKeyPair();
|
|
142
142
|
} else {
|
|
@@ -175,8 +175,8 @@ export class SampleApp {
|
|
|
175
175
|
async main() {
|
|
176
176
|
console.log('CUSTOM STARTUP');
|
|
177
177
|
await Registry.init();
|
|
178
|
-
const
|
|
179
|
-
|
|
178
|
+
const config = await DependencyRegistryIndex.getInstance(WebHttpConfig);
|
|
179
|
+
config.tls = true;
|
|
180
180
|
|
|
181
181
|
// Configure server before running
|
|
182
182
|
const instance = await DependencyRegistryIndex.getInstance(toConcrete<WebHttpServer>());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/web-http",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.2",
|
|
4
4
|
"description": "Web HTTP Server Support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"directory": "module/web-http"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/web": "^7.0.0-rc.
|
|
29
|
+
"@travetto/web": "^7.0.0-rc.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@travetto/cli": "^7.0.0-rc.0",
|
package/src/config.ts
CHANGED
|
@@ -51,11 +51,11 @@ export class WebHttpConfig {
|
|
|
51
51
|
this.bindAddress ||= await NetUtil.getLocalAddress();
|
|
52
52
|
|
|
53
53
|
if (!this.tls) {
|
|
54
|
-
// Clear out keys if
|
|
54
|
+
// Clear out keys if tls is not set
|
|
55
55
|
this.tlsKeys = undefined;
|
|
56
56
|
} else if (!this.tlsKeys) {
|
|
57
57
|
if (Runtime.production) {
|
|
58
|
-
throw new AppError('Default
|
|
58
|
+
throw new AppError('Default tls keys are only valid for development use, please specify a config value at web.tls.keys');
|
|
59
59
|
}
|
|
60
60
|
this.tlsKeys = await WebTlsUtil.generateKeyPair();
|
|
61
61
|
} else {
|
package/src/http.ts
CHANGED
|
@@ -19,7 +19,7 @@ type WebHttpServerConfig = {
|
|
|
19
19
|
httpVersion?: '1.1' | '2';
|
|
20
20
|
port: number;
|
|
21
21
|
bindAddress: string;
|
|
22
|
-
|
|
22
|
+
tlsKeys?: WebSecureKeyPair;
|
|
23
23
|
dispatcher: WebDispatcher;
|
|
24
24
|
signal?: AbortSignal;
|
|
25
25
|
};
|
|
@@ -48,14 +48,14 @@ export class WebHttpUtil {
|
|
|
48
48
|
|
|
49
49
|
let target: HttpServer;
|
|
50
50
|
if (config.httpVersion === '2') {
|
|
51
|
-
if (config.
|
|
52
|
-
target = http2.createSecureServer(config.
|
|
51
|
+
if (config.tlsKeys) {
|
|
52
|
+
target = http2.createSecureServer(config.tlsKeys, handler);
|
|
53
53
|
} else {
|
|
54
54
|
target = http2.createServer(handler);
|
|
55
55
|
}
|
|
56
56
|
} else {
|
|
57
|
-
if (config.
|
|
58
|
-
target = https.createServer(config.
|
|
57
|
+
if (config.tlsKeys) {
|
|
58
|
+
target = https.createServer(config.tlsKeys, handler);
|
|
59
59
|
} else {
|
|
60
60
|
target = http.createServer(handler);
|
|
61
61
|
}
|