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