Skip to content

Commit

Permalink
add exports to typescript index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmackrodt committed Dec 8, 2023
1 parent 97c88b0 commit 2ab772e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index.d.ts
65 changes: 64 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
declare module 'axios-cached-dns-resolve';
import type { AxiosInstance } from 'axios'
import type * as LRUCache from 'lru-cache'
import type { LoggerOptions } from 'pino'

declare module 'axios-cached-dns-resolve' {
export interface DnsEntry {
host: string
ips: string[]
nextIdx: number
lastUsedTs: number
updatedTs: number
}

export interface Config {
disabled: boolean
dnsTtlMs: number
cacheGraceExpireMultiplier: number
dnsIdleTtlMs: number
backgroundScanMs: number
dnsCacheSize: number
logging: LoggerOptions
cache?: LRUCache<string, DnsEntry>
}

export const config: Config

export interface CacheConfig {
max: number
ttl: number
}

export const cacheConfig: CacheConfig

export interface Stats {
dnsEntries: number
refreshed: number
hits: number
misses: number
idleExpired: number
errors: number
lastError: number
lastErrorTs: number
}

export const stats: Stats

export function init(): void

export function reset(): void

export function startBackgroundRefresh(): void

export function startPeriodicCachePrune(): void

export function getStats(): Stats

export function getDnsCacheEntries(): DnsEntry[]

export function registerInterceptor(axios: AxiosInstance): void

export function getAddress(host: string): Promise<string>

export function backgroundRefresh(axios: AxiosInstance): Promise<void>
}

0 comments on commit 2ab772e

Please sign in to comment.