Skip to content

zeabur/deno-typescript-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno-typescript-template

  • Use Deno.env.get("PORT") in your serving function.
import { serve } from "https://deno.land/[email protected]/http/server.ts";

function handler(_req: Request): Response {
  return new Response("Hello World!");
}

serve(handler, { port: Deno.env.get("PORT") });
  • Create a file deno.json and add the starting command.
{
  "tasks": {
    "start": "deno run --allow-net --allow-env --allow-read main.ts"
  }
}
  • To run locally, copy .env.defaults to a new file .env, and modify .env by assigning the port that you would like to run your application.

    cp .env.defaults .env
    # in .env
    PORT=<your port>