From af1ef45d72d94dbd94dd0771f457bb67708f5f72 Mon Sep 17 00:00:00 2001 From: linyyyang Date: Fri, 13 Jan 2023 16:06:25 +0800 Subject: [PATCH] fix: typeof server --- docs/api/koatty_serve.httpserver.start.md | 4 ++-- docs/api/koatty_serve.httpsserver.start.md | 4 ++-- docs/api/koatty_serve.wsserver.start.md | 4 ++-- src/http/http.ts | 6 +++--- src/http/http2.ts | 4 ++-- src/http/https.ts | 5 +++-- src/websocket/ws.ts | 6 +++--- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/api/koatty_serve.httpserver.start.md b/docs/api/koatty_serve.httpserver.start.md index 59335cd..9887d92 100644 --- a/docs/api/koatty_serve.httpserver.start.md +++ b/docs/api/koatty_serve.httpserver.start.md @@ -9,7 +9,7 @@ Start Server Signature: ```typescript -Start(listenCallback?: () => void): Server; +Start(listenCallback?: () => void): Server; ``` ## Parameters @@ -20,5 +20,5 @@ Start(listenCallback?: () => void): ServerReturns: -Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> +Server<typeof IncomingMessage, typeof ServerResponse> diff --git a/docs/api/koatty_serve.httpsserver.start.md b/docs/api/koatty_serve.httpsserver.start.md index cd7521b..dc4b079 100644 --- a/docs/api/koatty_serve.httpsserver.start.md +++ b/docs/api/koatty_serve.httpsserver.start.md @@ -9,7 +9,7 @@ Start Server Signature: ```typescript -Start(listenCallback?: () => void): Server; +Start(listenCallback?: () => void): Server; ``` ## Parameters @@ -20,5 +20,5 @@ Start(listenCallback?: () => void): ServerReturns: -Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> +Server<typeof IncomingMessage, typeof ServerResponse> diff --git a/docs/api/koatty_serve.wsserver.start.md b/docs/api/koatty_serve.wsserver.start.md index a9683a0..fcf77ab 100644 --- a/docs/api/koatty_serve.wsserver.start.md +++ b/docs/api/koatty_serve.wsserver.start.md @@ -9,7 +9,7 @@ Start Server Signature: ```typescript -Start(listenCallback?: () => void): HttpServer | HttpsServer; +Start(listenCallback?: () => void): HttpServer; ``` ## Parameters @@ -20,7 +20,7 @@ Start(listenCallback?: () => void): HttpServerReturns: -HttpServer<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> \| HttpsServer<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> +HttpServer<typeof IncomingMessage, typeof ServerResponse> {\*} WsServer diff --git a/src/http/http.ts b/src/http/http.ts index 7b5335d..2cc7dec 100644 --- a/src/http/http.ts +++ b/src/http/http.ts @@ -3,9 +3,9 @@ * @Usage: * @Author: richen * @Date: 2021-06-28 15:06:13 - * @LastEditTime: 2022-11-16 16:04:58 + * @LastEditTime: 2023-01-13 16:03:35 */ -import { createServer, Server } from "http"; +import { createServer, IncomingMessage, Server, ServerResponse } from "http"; import { Koatty, KoattyServer } from "koatty_core"; import { CreateTerminus } from "../terminus"; import { DefaultLogger as Logger } from "koatty_logger"; @@ -40,7 +40,7 @@ export class HttpServer implements KoattyServer { * @param {() => void} listenCallback * @memberof Http */ - Start(listenCallback?: () => void) { + Start(listenCallback?: () => void): Server { listenCallback = listenCallback ? listenCallback : this.listenCallback; return this.server.listen({ port: this.options.port, diff --git a/src/http/http2.ts b/src/http/http2.ts index b81722b..d14a426 100644 --- a/src/http/http2.ts +++ b/src/http/http2.ts @@ -3,7 +3,7 @@ * @Usage: * @Author: richen * @Date: 2021-06-28 15:06:13 - * @LastEditTime: 2022-11-16 16:05:09 + * @LastEditTime: 2023-01-13 16:04:05 */ import { createSecureServer, Http2SecureServer, SecureServerOptions } from "http2"; import { CreateTerminus } from "../terminus"; @@ -45,7 +45,7 @@ export class Http2Server implements KoattyServer { * @param {() => void} listenCallback * @memberof Http2Server */ - Start(listenCallback?: () => void) { + Start(listenCallback?: () => void): Http2SecureServer { listenCallback = listenCallback ? listenCallback : this.listenCallback; return this.server.listen({ port: this.options.port, diff --git a/src/http/https.ts b/src/http/https.ts index 441812b..29b699f 100644 --- a/src/http/https.ts +++ b/src/http/https.ts @@ -3,13 +3,14 @@ * @Usage: * @Author: richen * @Date: 2021-11-12 11:48:01 - * @LastEditTime: 2022-11-16 16:05:17 + * @LastEditTime: 2023-01-13 16:04:34 */ import { createServer, Server, ServerOptions } from "https"; import { Koatty, KoattyServer } from "koatty_core"; import { CreateTerminus } from "../terminus"; import { DefaultLogger as Logger } from "koatty_logger"; import { ListeningOptions } from "../index"; +import { IncomingMessage, ServerResponse } from "http"; /** * @@ -52,7 +53,7 @@ export class HttpsServer implements KoattyServer { * @param {() => void} listenCallback * @memberof Https */ - Start(listenCallback?: () => void) { + Start(listenCallback?: () => void): Server { listenCallback = listenCallback ? listenCallback : this.listenCallback; return this.server.listen({ port: this.options.port, diff --git a/src/websocket/ws.ts b/src/websocket/ws.ts index 9c3950d..ef4a025 100644 --- a/src/websocket/ws.ts +++ b/src/websocket/ws.ts @@ -3,13 +3,13 @@ * @Usage: * @Author: richen * @Date: 2021-11-12 11:29:16 - * @LastEditTime: 2022-11-16 16:05:42 + * @LastEditTime: 2023-01-13 16:05:07 */ import { DefaultLogger as Logger } from "koatty_logger"; import { Koatty, KoattyServer } from 'koatty_core'; import { ServerOptions, WebSocketServer } from 'ws'; import { CreateTerminus } from "../terminus"; -import { Server as HttpServer, createServer } from "http"; +import { Server as HttpServer, IncomingMessage, ServerResponse, createServer } from "http"; import { Server as HttpsServer, createServer as httpsCreateServer, ServerOptions as httpsServerOptions } from "https"; import { ListeningOptions } from "../index"; import { Helper } from "koatty_lib"; @@ -59,7 +59,7 @@ export class WsServer implements KoattyServer { * @returns {*} * @memberof WsServer */ - Start(listenCallback?: () => void) { + Start(listenCallback?: () => void): HttpServer { listenCallback = listenCallback ? listenCallback : this.listenCallback; return this.httpServer.listen({ port: this.options.port,