koatty_core
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -0,1 +1,7 @@ | ||
/** | ||
* @ author: richen | ||
* @ copyright: Copyright (c) - <richenlin(at)gmail.com> | ||
* @ license: BSD (3-Clause) | ||
* @ version: 2020-07-06 11:21:37 | ||
*/ | ||
import Koa from "koa"; | ||
@@ -37,3 +43,3 @@ import { Application } from "koatty_container"; | ||
status: number; | ||
Start: (openTrace: boolean, listenCallback: () => void) => void; | ||
Start: (listenCallback: () => void) => void; | ||
Stop: () => void; | ||
@@ -172,3 +178,3 @@ } | ||
* | ||
* @param {Function} serve (app: Koatty, options: ListeningOptions, listenCallback: () => void) => void | ||
* @param {Function} createServer (app: Koatty) => KoattyServer | ||
* @param {Function} [listeningListener] () => void | ||
@@ -178,3 +184,3 @@ * @returns {void} void | ||
*/ | ||
listen(serve: any, listeningListener?: any): any; | ||
listen(createServer: any, listeningListener?: any): any; | ||
/** | ||
@@ -181,0 +187,0 @@ * registration exception handling |
@@ -11,3 +11,2 @@ "use strict"; | ||
*/ | ||
const fs_1 = tslib_1.__importDefault(require("fs")); | ||
const koa_1 = tslib_1.__importDefault(require("koa")); | ||
@@ -160,3 +159,3 @@ const Helper = tslib_1.__importStar(require("koatty_lib")); | ||
* | ||
* @param {Function} serve (app: Koatty, options: ListeningOptions, listenCallback: () => void) => void | ||
* @param {Function} createServer (app: Koatty) => KoattyServer | ||
* @param {Function} [listeningListener] () => void | ||
@@ -166,33 +165,5 @@ * @returns {void} void | ||
*/ | ||
listen(serve, listeningListener) { | ||
var _a, _b, _c; | ||
const protocol = this.config("protocol") || "http"; | ||
const port = process.env.PORT || process.env.APPPORT || this.config('app_port') || 3000; | ||
const hostname = process.env.IP || ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || this.config('app_host') || 'localhost'; | ||
const options = { | ||
hostname: hostname, | ||
port: port, | ||
protocol: protocol, | ||
ext: { | ||
key: "", | ||
cert: "", | ||
protoFile: "", | ||
} | ||
}; | ||
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; | ||
listen(createServer, listeningListener) { | ||
const server = createServer(this); | ||
return server.Start(listeningListener); | ||
} | ||
@@ -199,0 +170,0 @@ /** |
@@ -61,3 +61,3 @@ import Koa from "koa"; | ||
*/ | ||
export declare function CreateContext(ctx: Koa.Context, protocol?: string): KoattyContext; | ||
export declare function CreateContext(ctx: Koa.Context): KoattyContext; | ||
export {}; |
@@ -11,3 +11,3 @@ "use strict"; | ||
*/ | ||
function CreateContext(ctx, protocol) { | ||
function CreateContext(ctx) { | ||
const context = Object.create(ctx); | ||
@@ -14,0 +14,0 @@ context.throw = function (statusOrMessage, codeOrMessage = 1, status) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
* @Date: 2021-11-16 14:46:22 | ||
* @LastEditTime: 2021-11-16 20:58:12 | ||
* @LastEditTime: 2021-11-16 21:17:23 | ||
*/ | ||
@@ -13,0 +13,0 @@ const events_1 = tslib_1.__importDefault(require("events")); |
{ | ||
"name": "koatty_core", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Koatty routing component, adapt to http1/2, websocket, gRPC.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
2097051
894