0Pricing
Edge Computing with Cloudflare Workers & Deno · บทเรียน

Deno Deploy และ CLI

ใช้ Deno Deploy เพื่อนำแอปพลิเคชัน Deno ไปใช้งานใกล้ผู้ใช้โดยตรง พร้อมเรียนรู้ฟีเจอร์ CLI ขั้นสูง

Deno Deploy และ CLI เป็นบทเรียน Edge Computing with Cloudflare Workers & Deno ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Edge Computing with Cloudflare Workers & Deno และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Edge Computing with Cloudflare Workers & Deno มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Welcome to Deno Deploy

In this lesson, we'll dive into Deno Deploy, a powerful platform designed for deploying Deno applications directly to the edge. It's built by the Deno team itself!

Think of it as a serverless environment optimized specifically for Deno, offering incredible speed and global reach without complex setup.

Deno Deploy's Core Philosophy

Deno Deploy simplifies edge deployment by letting you run your Deno code without complex build steps or configuration. It focuses on:

  • Simplicity: Deploy with a single command.
  • Speed: Your applications run on a globally distributed network.
  • Deno-Native: Your Deno code runs as-is, no transpilation needed.

This means less overhead and faster development cycles compared to other edge platforms.

Getting Started with Deno Deploy CLI

To deploy your Deno application, you'll primarily use the deno deploy command-line interface (CLI). First, ensure you have Deno installed.

You'll also need a Deno Deploy account to link your deployments. It's free to get started!

The CLI handles authentication and project management for you.

Your First Edge Function

Let's create a simple Deno HTTP server. Save this code as main.ts. It will respond with 'Hello from Deno Deploy!' when accessed.

This is a complete, runnable Deno program, ready for the edge:

import { serve } from "https://deno.land/std@0.210.0/http/server.ts";

const handler = (_req: Request): Response => {
  return new Response("Hello from Deno Deploy!");
};

serve(handler, { port: 8000 });
console.log("Server running on http://localhost:8000/");

Deploying Your Application

Once you have your Deno code (like main.ts), deploying it is straightforward. You'll use the deno deploy command.

You can create a project via the Deno Deploy dashboard or let the CLI create one for you.

Example deployment command:

deno deploy --project=<your-project-name> main.ts

Monitoring with Deno Deploy CLI

After deployment, you'll want to check its status and view logs. The Deno Deploy CLI provides convenient commands for this:

  • deno deploy status [project-name]: Shows information about your project's deployments, including URLs and status.
  • deno deploy logs [project-name]: Streams real-time logs from your running application, vital for debugging.

These tools are crucial for maintaining and debugging your edge functions.

Environment Variables & Secrets

Edge applications often need configuration or secrets (like API keys). Deno Deploy supports environment variables for this.

You define these variables in your project's settings on the Deno Deploy dashboard. They are securely injected into your application's runtime.

In your Deno code, you access them using Deno.env.get("VAR_NAME").

Using Environment Variables in Code

Let's update our Deno server to use an environment variable. Imagine we set GREETING_MESSAGE in the Deno Deploy dashboard.

This makes your application more flexible and secure by separating configuration from code:

import { serve } from "https://deno.land/std@0.210.0/http/server.ts";

const greeting = Deno.env.get("GREETING_MESSAGE") || "Hello from default!";

const handler = (_req: Request): Response => {
  return new Response(greeting);
};

serve(handler, { port: 8000 });
console.log("Server running on http://localhost:8000/");

Advanced Deployment Options

Deno Deploy offers more advanced features to enhance your workflow and application:

  • Git Integration: Connect your GitHub repository for automatic deployments on every push.
  • Custom Domains: Map your own domain names to your deployed applications for brand consistency.
  • Production Flag: Use --production with the CLI for optimized production deployments.

These features streamline your CI/CD pipeline and improve the user experience.

Deno Deploy CLI Question

Which of the following commands would you use to view real-time logs from your deployed Deno Deploy application?

Recap: Deno Deploy & CLI

You've learned about Deno Deploy, a Deno-native platform for edge deployment. We covered:

  • Its core benefits: simplicity, speed, and Deno-native execution.
  • Using the deno deploy CLI for simple and advanced deployments.
  • Managing environment variables for secure configuration.
  • Monitoring your applications with deno deploy status and logs.

Deno Deploy offers a powerful, streamlined way to bring your Deno applications directly to the edge!

คำถามที่พบบ่อย

บทเรียน “Deno Deploy และ CLI” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “Deno Deploy และ CLI” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Edge Computing with Cloudflare Workers & Deno ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Edge Computing with Cloudflare Workers & Deno มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “Deno Deploy และ CLI”

ใช้ Deno Deploy เพื่อนำแอปพลิเคชัน Deno ไปใช้งานใกล้ผู้ใช้โดยตรง พร้อมเรียนรู้ฟีเจอร์ CLI ขั้นสูง คุณปฏิบัติ Edge Computing with Cloudflare Workers & Deno ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Edge Computing with Cloudflare Workers & Deno หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Edge Computing with Cloudflare Workers & Deno บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “Deno Deploy และ CLI” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Edge Computing with Cloudflare Workers & Deno นี้ได้ไหม

ได้ บทเรียน Edge Computing with Cloudflare Workers & Deno ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. Deno Deploy และ CLI
  2. สภาพแวดล้อมรันไทม์แบบกำหนดเอง
  3. การทดสอบและ CI/CD สำหรับระบบใกล้ผู้ใช้
  4. การปรับใช้แบบน้ำเงิน-เขียวและทยอยเปิดใช้งาน
← กลับไปที่ Edge Computing with Cloudflare Workers & Deno