Created
          June 30, 2021 06:24 
        
      - 
      
- 
        Save mayankchoubey/6a802744d2227d28cd5677679bed1ef0 to your computer and use it in GitHub Desktop. 
    URL shortener - server.ts
  
        
  
    
      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}); | |
| for await(const conn of listener) | |
| handleNewConnection(conn); | |
| async function handleNewConnection(conn: Deno.Conn) { | |
| for await(const req of Deno.serveHttp(conn)) | |
| await handleRequest(req.request, req.respondWith); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment