async function handleRequest(request) {

  const head = {
    headers : {
      'content-type' : 'text/html'
    }
  }
  let url = ""
  let cookies = request.headers.get("Cookie") || "empty"
  let setCookie = false

  //checking for cookie
  if(cookies.localeCompare("empty") != 0){
    url = extractCookie(cookies)
  }

  //extract from json api
  if(url.localeCompare("") == 0) {
    url = await urlApi();
    setCookie = true;
  }
  
  const htmlModifier = new HTMLRewriter().on("h1[id=title]",new modifyPara(1)).on("p[id=description]",new modifyPara(2))
                        .on("a[id=url]",new modifyPara(3)).on("title",new modifyPara(0));


  const data = await fetch(url)
              .then(data => htmlModifier.transform(data))
              .then(html => html.text())
        
  op = new Response(data,head)
  
  if(setCookie)
    op.headers.set("Set-Cookie","url="+url)

  return op;
}
/**
 * request handler contains main logic
 * @param {Request} request
 */
request handler contains main logic
@param {Request} request
request handler contains main logic @param { Request } request
async function handleRequest(request) {
  const head = {
    headers : {
      'content-type' : 'text/html'
    }
  }
  let url = ""
  let cookies = request.headers.get("Cookie") || "empty"
  let setCookie = false
  if(cookies.localeCompare("empty") != 0){
    url = extractCookie(cookies)
  }
  if(url.localeCompare("") == 0) {
    url = await urlApi();
    setCookie = true;
  }
  const htmlModifier = new HTMLRewriter().on("h1[id=title]",new modifyPara(1)).on("p[id=description]",new modifyPara(2))
                        .on("a[id=url]",new modifyPara(3)).on("title",new modifyPara(0));
  const data = await fetch(url)
              .then(data => htmlModifier.transform(data))
              .then(html => html.text())
  op = new Response(data,head)
  if(setCookie)
    op.headers.set("Set-Cookie","url="+url)
  return op;
}
async function handleRequest ( request ) { const head = { headers : { 'content-type' : 'text/html' } } let url = "" let cookies = request . headers . get ( "Cookie" ) || "empty" let setCookie = false if ( cookies . localeCompare ( "empty" ) != 0 ) { url = extractCookie ( cookies ) } if ( url . localeCompare ( "" ) == 0 ) { url = await urlApi ( ) ; setCookie = true ; } const htmlModifier = new HTMLRewriter ( ) . on ( "h1[id=title]" , new modifyPara ( 1 ) ) . on ( "p[id=description]" , new modifyPara ( 2 ) ) . on ( "a[id=url]" , new modifyPara ( 3 ) ) . on ( "title" , new modifyPara ( 0 ) ) ; const data = await fetch ( url ) . then ( data => htmlModifier . transform ( data ) ) . then ( html => html . text ( ) ) op = new Response ( data , head ) if ( setCookie ) op . headers . set ( "Set-Cookie" , "url=" + url ) return op ; }
request handler contains main logic
 @param {Request} request
request handler contains main logic @param { Request } request
//checking for cookie //extract from json api