Skip to content

Commit

Permalink
refactor(connifo): create types.ts for type definitions (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Jun 6, 2024
1 parent fd6ad5e commit 8c5463f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 45 deletions.
46 changes: 1 addition & 45 deletions src/helper/conninfo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
45 changes: 45 additions & 0 deletions src/helper/conninfo/types.ts
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c5463f

Please sign in to comment.