import { Cookies } from './cookies.js' ; import { Req } from './req.js' ; import { ResponseBuilder } from './response-builder.js' ; export class Context { public readonly req : Req ; public readonly res : ResponseBuilder ; public readonly cookies : Cookies ; public readonly respondWith ! : ( response : Response ) => void ; public readonly responded : Promise < Response > ; public readonly state : any ; constructor ( private readonly event ) { const request = event . request ; this . req = new Req ( request ) ; this . res = new ResponseBuilder ( ) ; this . cookies = new Cookies ( request . headers , this . res . headers ) ; this . responded = new Promise < Response > ( resolve => { this . respondWith = resolve ; } ) ; this . state = { } ; } public waitUntil ( promise ) { this . event . waitUntil ( promise ) ; } }