koatty_core
Advanced tools
Comparing version 1.1.11 to 1.2.2
@@ -5,2 +5,4 @@ # Changelog | ||
### [1.2.2](https://github.com/koatty/koatty_core/compare/v1.1.4...v1.2.2) (2021-11-12) | ||
### [1.1.4](https://github.com/koatty/koatty_core/compare/v1.1.2...v1.1.4) (2021-11-11) | ||
@@ -7,0 +9,0 @@ |
@@ -1,7 +0,1 @@ | ||
/** | ||
* @ author: richen | ||
* @ copyright: Copyright (c) - <richenlin(at)gmail.com> | ||
* @ license: BSD (3-Clause) | ||
* @ version: 2020-07-06 11:21:37 | ||
*/ | ||
import Koa from "koa"; | ||
@@ -71,3 +65,13 @@ import { Application } from "koatty_container"; | ||
strict?: boolean; | ||
/** | ||
* Server protocol, 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss' | ||
*/ | ||
protocol: string; | ||
/** | ||
* gRPC protocol file | ||
*/ | ||
protoFile?: string; | ||
/** | ||
* Other extended configuration | ||
*/ | ||
ext?: any; | ||
@@ -74,0 +78,0 @@ } |
@@ -11,2 +11,3 @@ "use strict"; | ||
*/ | ||
const fs_1 = tslib_1.__importDefault(require("fs")); | ||
const koa_1 = tslib_1.__importDefault(require("koa")); | ||
@@ -164,4 +165,4 @@ const Helper = tslib_1.__importStar(require("koatty_lib")); | ||
listen(serve, listeningListener) { | ||
var _a; | ||
const protocol = this.config("protocol") || "http"; // 'http' | 'https' | 'grpc' | 'ws' | 'wss' | ||
var _a, _b, _c; | ||
const protocol = this.config("protocol") || "http"; | ||
const port = process.env.PORT || process.env.APPPORT || this.config('app_port') || 3000; | ||
@@ -173,11 +174,23 @@ const hostname = process.env.IP || ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || this.config('app_host') || 'localhost'; | ||
protocol: protocol, | ||
// listenUrl: `${protocol}://${hostname || '127.0.0.1'}:${port}/`, | ||
ext: { | ||
// key: "", | ||
// cert: "", | ||
// protoFile: "", | ||
}, | ||
key: "", | ||
cert: "", | ||
protoFile: "", | ||
} | ||
}; | ||
// serve and start | ||
serve(this, options, listeningListener); | ||
const pm = new Set(["https", "http2", "wss"]); | ||
if (pm.has(protocol)) { | ||
const keyFile = (_b = this.config("key_file")) !== null && _b !== void 0 ? _b : ""; | ||
const crtFile = (_c = this.config("crt_file")) !== null && _c !== void 0 ? _c : ""; | ||
options.ext.key = fs_1.default.readFileSync(keyFile).toString(); | ||
options.ext.cert = fs_1.default.readFileSync(crtFile).toString(); | ||
} | ||
if (protocol === "https" || protocol === "http2") { | ||
options.port = options.port == 80 ? 443 : options.port; | ||
} | ||
if (protocol === "grpc") { | ||
const proto = this.config("protoFile", "router"); | ||
options.ext.protoFile = proto; | ||
} | ||
serve(this, options, listeningListener(this, options)); | ||
return null; | ||
@@ -184,0 +197,0 @@ } |
{ | ||
"name": "koatty_core", | ||
"version": "1.1.11", | ||
"version": "1.2.2", | ||
"description": "Koatty routing component, adapt to http1/2, websocket, gRPC.", | ||
@@ -64,2 +64,2 @@ "scripts": { | ||
} | ||
} | ||
} |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
1804375
758
7