---
title: Making a Deno 2 app in 15 minutes
url: https://calvin.my/posts/making-a-deno-2-app-in-15-minutes
published: 2024-10-27
updated: 2026-09-17
category: Development
tags:
- Javascript
- Deno
- Web
summary: The post introduces Deno 2 through a quick build of a command-line app that sends user prompts to OpenAI and displays responses. It covers installing the runtime, writing a script to collect input and call the API, and running it with Deno’s explicit network-permission model. Finally, it shows how to compile the script into a standalone executable for sharing, highlighting Deno’s streamlined development and distribution workflow.
---

# Making a Deno 2 app in 15 minutes

[Deno](https://deno.com/) is an open-source JavaScript runtime, and its version 2 was recently announced. This article demonstrates how to set up, develop, and build a simple Deno app.

* * *

## Setup

1. The setup is just 1 step.

   ```bash
   # Mac / Linux
   curl -fsSL https://deno.land/install.sh | sh

   # Windows
   irm https://deno.land/install.ps1 | iex
   ```

2. Restart your terminal to load Deno.

3. Check if Deno is loaded by running this command.

   ```bash
   deno --help
   ```
* * *
## Develop

1. Our goal is to create a command line application. It should ask the user to enter a prompt and get OpenAI GPT to react based on the prompt.

2. Start by creating a new script file, for example, main.ts

3. First, we create a function that accepts a string input.

   ```javascript
   function fetchCompletion(prompt: string) {
   }
   ```

4. Then, we send the input to the OpenAI completion endpoint.

   ```javascript
   function fetchCompletion(prompt: string) {
     return fetch("https://api.openai.com/v1/chat/completions", {
       method: "POST",
       headers: {
         "Content-Type": "application/json",
         "Authorization": `Bearer ${"sk-1234"}`,
       },
       body: JSON.stringify({
         model: "gpt-4o",
         messages: [
           { role: "system", content: "You are a helpful assistant." },
           { role: "user", content: prompt },
         ]
       }),
     });
   }
   ```

5. We also want to get an input from the user.

   ```javascript
   const input = prompt("Hello! How can I help you today?");
   ```

6. Finally, we send the user's input into our fetchCompletion function and print the first choice returned by gpt-4o.

   ```javascript
   if (input) {
       // fetch and display the completion
       fetchCompletion(input)
       .then((response) => response.json())
       .then((data) => {
           console.log(data["choices"][0]["message"]["content"]);
       });
   }
   ```
* * *
## Trial Run

1. We can run our code from the terminal using deno run.

   ```bash
   deno run main.ts
   ```

2. Now, permission is required because our application accesses the network. Deno prompts such permission requests when the application is trying to access sensitive API. For example, reading file systems and accessing networks.&nbsp;

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/a548d15c-a4e6-487c-942f-2a0ff58e3888.png)

3. You can type "Y" to allow and continue running. You can also declare the permission when you execute the run command.

   ```bash
   deno run --allow-net main.ts
   ```

4. Once the code executes, the result is rendered in the terminal. As expected.

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/9641a935-eb49-40f8-b995-155514bca777.png)
* * *
## Build & Deploy

1. We can build this little application and share it with our friends.

2. Run this compile command.

   ```bash
   deno compile -R --allow-net main.ts
   ```

3. An executable file is created.

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/099af444-7df5-4a66-933a-1d75b89e6e73.png)

4. The executable does exactly what it is built for.

   ![](https://camy-pub.s3.ap-southeast-1.amazonaws.com/83aa951f-8cb4-4c7f-80c6-560c0943f18d.png)
