fix: use generics type for env argument in callback type

pull/135/head
mst-mkt 2025-08-07 16:01:11 +09:00
parent a7a43c0e29
commit 1e3ae56298
1 changed files with 7 additions and 5 deletions

View File

@ -1,3 +1,5 @@
import type { Env } from '../worker/src'
export type PageConfig = { export type PageConfig = {
title?: string title?: string
links?: PageConfigLink[] links?: PageConfigLink[]
@ -39,12 +41,12 @@ export type MonitorTarget = {
checkProxyFallback?: boolean checkProxyFallback?: boolean
} }
export type WorkerConfig = { export type WorkerConfig<TEnv = Env> = {
kvWriteCooldownMinutes: number kvWriteCooldownMinutes: number
passwordProtection?: string passwordProtection?: string
monitors: MonitorTarget[] monitors: MonitorTarget[]
notification?: Notification notification?: Notification
callbacks?: Callbacks callbacks?: Callbacks<TEnv>
} }
export type Notification = { export type Notification = {
@ -55,9 +57,9 @@ export type Notification = {
skipNotificationIds?: string[] skipNotificationIds?: string[]
} }
export type Callbacks = { export type Callbacks<TEnv = Env> = {
onStatusChange?: ( onStatusChange?: (
env: any, env: TEnv,
monitor: MonitorTarget, monitor: MonitorTarget,
isUp: boolean, isUp: boolean,
timeIncidentStart: number, timeIncidentStart: number,
@ -65,7 +67,7 @@ export type Callbacks = {
reason: string reason: string
) => Promise<any> | any ) => Promise<any> | any
onIncident?: ( onIncident?: (
env: any, env: TEnv,
monitor: MonitorTarget, monitor: MonitorTarget,
timeIncidentStart: number, timeIncidentStart: number,
timeNow: number, timeNow: number,