declare const self ; import { HandlerContext , Router } from '../../src/router' ; interface RequestContext { importantInfo : number ; } interface Context extends HandlerContext { ctx : RequestContext ; } const router = new Router ( ) ; const user = async ( { request , params } ) : Promise < Response > => { const headers = new Headers ( { 'x-user-id' : params . id } ) ; const response = new Response ( `Hello user with id ${ params . id }.` , { headers } ) ; return response ; } ; const info = async ( { ctx } ) : Promise < Response > => { const response = new Response ( `Important info: ${ ctx . importantInfo }.` ) ; return response ; } ; const postPing = async ( ) => new Response ( 'post pong' ) ; const ping = async ( ) => new Response ( 'pong' ) ; const foobar = async ( ) => new Response ( 'foobar' , { status : 201 } ) ; router . get ( '/user/:id' , user ) ; router . post ( '/_ping' , postPing ) ; router . all ( '/_ping' , ping ) ; router . all ( '/info' , info ) ; router . get ( '(http(s)\\://)api.foobar.com/hello' , foobar , { matchUrl : true } ) ; router . all ( '/throw' , async ( ) => { throw new Error ( 'Nope!' ) ; } ) ; router . ctx = { importantInfo : 42 } as RequestContext ; self . addEventListener ( 'fetch' , ( event ) => { router . handleEvent ( event ) ; } ) ;