This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export const enum ProgressIndicatorType { | |
| BAR, | |
| PERCENT, | |
| DOTS | |
| }; | |
| export class ProgressIndicator { | |
| private numUnits:number; | |
| private nextUpdateTS:number=Date.now(); | |
| private enc:TextEncoder=new TextEncoder(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {PORT as port} from "./constants.ts"; | |
| import {handleRequest} from "./router.ts"; | |
| if(!window.location) { | |
| console.error("ERROR: Location must be specified with --location"); | |
| Deno.exit(1); | |
| } | |
| const listener = Deno.listen({port}); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {Status} from "https://deno.land/std/http/http_status.ts"; | |
| import {HTTP_METHOD_GET, HTTP_METHOD_POST, ROUTE_SHORTEN, QUERY_PARAM_TARGET} from "./constants.ts"; | |
| import {getTarget, addTarget} from "./controller.ts"; | |
| import {sendResponseCode} from "./utils.ts"; | |
| export async function handleRequest(req: Request, resp: any) { | |
| const u=new URL(req.url); | |
| const path=u.pathname, target=u.searchParams.get(QUERY_PARAM_TARGET); | |
| switch(req.method) { | |
| case HTTP_METHOD_GET: { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {Status} from "https://deno.land/std/http/http_status.ts" | |
| import {sendResponseCode, sendResponseRedirect, sendResponseShortenedUrl} from "./utils.ts"; | |
| import {get,add} from "./service.ts"; | |
| export function getTarget(resp: any, urlCode: string) { | |
| const target=get(urlCode); | |
| if(!target) | |
| return sendResponseCode(resp, Status.NotFound); | |
| sendResponseRedirect(resp, target); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {getId} from "./utils.ts"; | |
| export function add(target:string) { | |
| const id=getId(); | |
| localStorage.setItem(id, target); | |
| return id; | |
| } | |
| export function get(id:string) { | |
| return localStorage.getItem(id.startsWith('/')?id.slice(1): id); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export const PORT=80; | |
| export const ROUTE_SHORTEN='/shorten'; | |
| export const HTTP_METHOD_GET='GET'; | |
| export const HTTP_METHOD_POST='POST'; | |
| export const HEADER_LOCATION='location'; | |
| export const QUERY_PARAM_TARGET='target'; | |
| export const URL_CODE_LENGTH=8; | |
| export const SERVICE_DOMAIN='http://sho.rt/'; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const listener = Deno.listen({ port: 3000 }); | |
| for await(const conn of listener) | |
| handleNewConnection(conn); | |
| async function handleNewConnection(conn: Deno.Conn) { | |
| for await(const { request, respondWith } of Deno.serveHttp(conn)) { | |
| const reqBody=await request.json(); | |
| if(reqBody) { | |
| respondWith(new Response(JSON.stringify({ name: reqBody.name }), { | |
| headers: { 'content-type': 'application/json'} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.example.demo; | |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| import org.springframework.web.bind.annotation.PostMapping; | |
| import org.springframework.web.bind.annotation.RequestBody; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.web.bind.annotation.RestController; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {readableStreamFromReader as toStream} from "https://deno.land/std/io/mod.ts"; | |
| const baseServePath='/Users/mayankc/Work/source/deno-vs-nodejs/testdata'; | |
| const listener = Deno.listen({ port: 3000 }); | |
| for await(const conn of listener) | |
| handleNewConnection(conn); | |
| async function handleNewConnection(conn: Deno.Conn) { | |
| for await(const {request:req, respondWith:res} of Deno.serveHttp(conn)) { | |
| const filePath=baseServePath+(new URL(req.url)).pathname; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import {readerFromStreamReader, copy} from "https://deno.land/std/streams/mod.ts"; | |
| const basePath=Deno.env.get('TMPDIR'); | |
| const listener = Deno.listen({ port: 3000 }); | |
| for await(const conn of listener) | |
| handleNewConnection(conn); | |
| async function handleNewConnection(conn: Deno.Conn) { | |
| for await(const { request, respondWith } of Deno.serveHttp(conn)) { | |
| const reqBody=await request.formData(); |