Bird
Raised Fist0
Denoframework~10 mins

Deploying to Deno Deploy - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Deno Deploy standard HTTP server.

Deno
import { serve } from "https://deno.land/std/http/[1]";
Drag options to blanks, or click blank then click option'
Aserve.ts
Bhttp.ts
Cserver.tsx
Dserver.ts
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'server.tsx' which is for React components, not HTTP server.
Using 'serve.ts' which does not exist in the standard library.
Using 'http.ts' which is not the correct file name.
2fill in blank
medium

Complete the code to start the HTTP server and respond with 'Hello from Deno Deploy!'.

Deno
serve((req) => new Response("Hello from [1]!"));
Drag options to blanks, or click blank then click option'
ADeno Deploy
BNode.js
CCloudflare
DAWS Lambda
Attempts:
3 left
💡 Hint
Common Mistakes
Using other platform names like 'Node.js' or 'AWS Lambda' in the message.
Leaving the message blank or generic.
3fill in blank
hard

Fix the error in the deployment script by completing the missing command to deploy to Deno Deploy.

Deno
deno deploy [1]
Drag options to blanks, or click blank then click option'
A--import-map
B--project
C--token
D--name
Attempts:
3 left
💡 Hint
Common Mistakes
Using --token which is for authentication, not project name.
Using --name which is not a valid flag.
Using --import-map which is unrelated to deployment name.
4fill in blank
hard

Fill both blanks to create a simple Deno Deploy handler that returns JSON with a message and status code.

Deno
serve((req) => new Response(JSON.stringify({ message: "[1]" }), { status: [2] }));
Drag options to blanks, or click blank then click option'
AHello from Deno Deploy
B200
C404
DGoodbye
Attempts:
3 left
💡 Hint
Common Mistakes
Using a 404 status code for a successful response.
Using a goodbye message instead of a greeting.
5fill in blank
hard

Fill all three blanks to create a Deno Deploy handler that reads a query parameter 'name' and responds with a personalized greeting or a default message.

Deno
serve((req) => {
  const url = new URL(req.url);
  const name = url.searchParams.get("[1]") || "[2]";
  return new Response(`Hello, $[3]!`);
});
Drag options to blanks, or click blank then click option'
Ausername
BGuest
Cname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' instead of 'name' as the query parameter.
Using an undefined variable in the greeting string.

Practice

(1/5)
1. What is the main purpose of deno deploy in Deno?
easy
A. To run Deno scripts locally without internet
B. To install Deno on your computer
C. To create a new Deno project template
D. To publish your Deno app online as a serverless function

Solution

  1. Step 1: Understand the command purpose

    deno deploy is used to publish apps online, not for local installs or running scripts.
  2. Step 2: Match the description to the command

    Publishing as serverless functions matches the description of deno deploy.
  3. Final Answer:

    To publish your Deno app online as a serverless function -> Option D
  4. Quick Check:

    deno deploy = publish app online [OK]
Hint: Remember: deploy means publish online [OK]
Common Mistakes:
  • Confusing deploy with install
  • Thinking deploy runs code locally
  • Assuming deploy creates projects
2. Which of the following is the correct command to deploy a Deno project located in the current folder?
easy
A. deno deploy --install
B. deno deploy .
C. deno run deploy
D. deno start deploy

Solution

  1. Step 1: Identify the correct deploy syntax

    The command deno deploy . tells Deno to deploy the current folder project.
  2. Step 2: Check other options for correctness

    Options B, C, and D are invalid commands for deployment.
  3. Final Answer:

    deno deploy . -> Option B
  4. Quick Check:

    Deploy current folder = deno deploy . [OK]
Hint: Use dot (.) to deploy current folder [OK]
Common Mistakes:
  • Using deno run instead of deno deploy
  • Adding wrong flags like --install
  • Using deno start which is not a Deno command
3. Given this command run in your terminal: deno deploy https://github.com/user/myapp, what will happen?
medium
A. Deno will deploy the app from the GitHub repo URL as a serverless app
B. Deno will clone the repo locally but not deploy
C. Deno will throw a syntax error because URLs are not allowed
D. Deno will run the app locally without deploying

Solution

  1. Step 1: Understand deploying from a repo URL

    Deno Deploy supports deploying directly from GitHub repo URLs.
  2. Step 2: Analyze the command behavior

    The command deploys the app serverlessly from the given URL, no local clone or syntax error occurs.
  3. Final Answer:

    Deno will deploy the app from the GitHub repo URL as a serverless app -> Option A
  4. Quick Check:

    Deploy from URL = deploy serverless app [OK]
Hint: Deploy accepts GitHub URLs directly [OK]
Common Mistakes:
  • Thinking deploy clones repo locally
  • Assuming URLs cause syntax errors
  • Confusing deploy with local run
4. You run deno deploy myapp but get an error saying "No such file or directory". What is the most likely cause?
medium
A. You forgot to install Deno before deploying
B. The internet connection is down
C. The folder or file named 'myapp' does not exist in the current directory
D. You need to run deno run myapp first

Solution

  1. Step 1: Interpret the error message

    "No such file or directory" means the path 'myapp' is missing locally.
  2. Step 2: Match error to cause

    Since deploy expects a valid path or URL, missing folder causes this error.
  3. Final Answer:

    The folder or file named 'myapp' does not exist in the current directory -> Option C
  4. Quick Check:

    Missing folder = No such file error [OK]
Hint: Check folder exists before deploying [OK]
Common Mistakes:
  • Assuming Deno is not installed
  • Blaming internet connection for local file errors
  • Confusing deploy with run command
5. You want to deploy a Deno app that uses environment variables securely on Deno Deploy. Which approach is best?
hard
A. Set environment variables in Deno Deploy dashboard and access them via Deno.env.get()
B. Hardcode environment variables in your source code before deploying
C. Pass environment variables as command line arguments to deno deploy
D. Store environment variables in a local .env file and deploy it with your app

Solution

  1. Step 1: Understand environment variable best practices

    Hardcoding or deploying .env files risks exposing secrets publicly.
  2. Step 2: Use Deno Deploy features

    Deno Deploy dashboard allows secure environment variable setup accessed by Deno.env.get().
  3. Final Answer:

    Set environment variables in Deno Deploy dashboard and access them via Deno.env.get() -> Option A
  4. Quick Check:

    Secure env vars = dashboard + Deno.env.get() [OK]
Hint: Use dashboard for env vars, not code files [OK]
Common Mistakes:
  • Hardcoding secrets in code
  • Uploading .env files publicly
  • Trying to pass env vars via deploy command
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard