From 8c5463f62b283a59e674e16de1c6a88445c0a2ba Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 6 Jun 2024 22:55:37 +0900 Subject: [PATCH] refactor(connifo): create `types.ts` for type definitions (#2924) --- src/helper/conninfo/index.ts | 46 +----------------------------------- src/helper/conninfo/types.ts | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 src/helper/conninfo/types.ts diff --git a/src/helper/conninfo/index.ts b/src/helper/conninfo/index.ts index 7aa0a6723..b3a11c204 100644 --- a/src/helper/conninfo/index.ts +++ b/src/helper/conninfo/index.ts @@ -3,48 +3,4 @@ * ConnInfo Helper for Hono. */ -import type { Context } from '../../context' - -export type AddressType = 'IPv6' | 'IPv4' | 'unknown' - -export type NetAddrInfo = { - /** - * Transport protocol type - */ - transport?: 'tcp' | 'udp' - /** - * Transport port number - */ - port?: number - - address?: string - addressType?: AddressType -} & ( - | { - /** - * Host name such as IP Addr - */ - address: string - - /** - * Host name type - */ - addressType: AddressType - } - | {} -) - -/** - * HTTP Connection infomation - */ -export interface ConnInfo { - /** - * Remote infomation - */ - remote: NetAddrInfo -} - -/** - * Helper type - */ -export type GetConnInfo = (c: Context) => ConnInfo +export type { AddressType, NetAddrInfo, ConnInfo, GetConnInfo } from './types' diff --git a/src/helper/conninfo/types.ts b/src/helper/conninfo/types.ts new file mode 100644 index 000000000..ce0ef9fed --- /dev/null +++ b/src/helper/conninfo/types.ts @@ -0,0 +1,45 @@ +import type { Context } from '../../context' + +export type AddressType = 'IPv6' | 'IPv4' | 'unknown' + +export type NetAddrInfo = { + /** + * Transport protocol type + */ + transport?: 'tcp' | 'udp' + /** + * Transport port number + */ + port?: number + + address?: string + addressType?: AddressType +} & ( + | { + /** + * Host name such as IP Addr + */ + address: string + + /** + * Host name type + */ + addressType: AddressType + } + | {} +) + +/** + * HTTP Connection infomation + */ +export interface ConnInfo { + /** + * Remote infomation + */ + remote: NetAddrInfo +} + +/** + * Helper type + */ +export type GetConnInfo = (c: Context) => ConnInfo