0Pricing
Edge Computing with Cloudflare Workers & Deno · Ders

Worker Ortamını Kurma

Wrangler CLI kullanarak yerel makinenizi Cloudflare Workers geliştirmesi için yapılandırın.

Worker Ortamını Kurma, CoddyKit'te ücretsiz bir Edge Computing with Cloudflare Workers & Deno dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Edge Computing with Cloudflare Workers & Deno öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Edge Computing with Cloudflare Workers & Deno kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Get Ready for Edge Dev

Welcome! Before we build our first Cloudflare Worker, we need to set up our local development environment. This ensures you have all the tools to write, test, and deploy your code efficiently.

A proper setup makes the development process smooth and helps you quickly iterate on your edge applications.

Wrangler: Your Worker Tool

Our primary tool for interacting with Cloudflare Workers is the Wrangler CLI (Command Line Interface). It's a powerful tool that helps you:

  • Create new Worker projects
  • Develop and test Workers locally
  • Configure and deploy Workers to Cloudflare's edge
  • Manage Worker resources

Essential: Node.js & npm

Wrangler is built using Node.js, so you'll need Node.js and its package manager, npm (or yarn), installed on your machine.

  • Node.js: A JavaScript runtime environment.
  • npm: Node Package Manager, used to install libraries and tools.

If you don't have Node.js, download it from nodejs.org. We recommend using a Long Term Support (LTS) version.

Installing Wrangler CLI

Once Node.js and npm are ready, open your terminal or command prompt. We'll install Wrangler globally so it's accessible from any directory.

Run the following command:

npm install -g wrangler

Connect to Cloudflare

After installing, you need to link Wrangler to your Cloudflare account. This allows Wrangler to deploy and manage Workers on your behalf.

Execute this command and follow the browser prompts to log in:

wrangler login

Create Your First Project

Now that Wrangler is installed and authenticated, let's create a new Worker project. This command generates a basic project structure for you.

Replace my-first-worker with your desired project name:

wrangler generate my-first-worker

Understanding Project Structure

After running wrangler generate, you'll find a new directory (e.g., my-first-worker) with essential files:

  • wrangler.toml: Your Worker's configuration file.
  • src/index.js: The main JavaScript file where your Worker's logic lives.
  • package.json: Standard Node.js package file (optional, for dependencies).

Let's dive into these key files.

Configure with wrangler.toml

The wrangler.toml file is crucial. It defines your Worker's settings, like its name, type, and associated Cloudflare account.

Here's a basic example of what it might contain:

name = "my-first-worker"
main = "src/index.js"
compatibility_date = "2023-10-26"
account_id = "YOUR_CLOUDFLARE_ACCOUNT_ID"

Your Worker's Logic

The src/index.js file is where you write the JavaScript code for your Worker. Cloudflare Workers typically listen for fetch events.

This simple Worker responds with "Hello Cloudflare Workers!" to any request:

export default {
  async fetch(request, env, ctx) {
    return new Response("Hello Cloudflare Workers!");
  },
};

Test Your Worker Locally

Before deploying, you can test your Worker right on your machine! Wrangler creates a local development server that simulates the Cloudflare edge environment.

Navigate into your project directory (e.g., cd my-first-worker) and run:

wrangler dev

Wrangler Command Check

Which Wrangler command is used to connect your local environment to your Cloudflare account?

Recap: Setup Complete!

Great job! You've successfully set up your Cloudflare Workers development environment. You've learned how to:

  • Install Wrangler CLI
  • Authenticate with Cloudflare
  • Generate a new Worker project
  • Understand the basic project structure
  • Run your Worker locally using wrangler dev

You're now ready to start building powerful applications at the edge!

Sıkça Sorulan Sorular

“Worker Ortamını Kurma” dersi ücretsiz mi?

Evet — “Worker Ortamını Kurma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Edge Computing with Cloudflare Workers & Deno kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Edge Computing with Cloudflare Workers & Deno kursu toplamda 4 dersten oluşur.

“Worker Ortamını Kurma” dersinde ne öğreneceğim?

Wrangler CLI kullanarak yerel makinenizi Cloudflare Workers geliştirmesi için yapılandırın. Edge Computing with Cloudflare Workers & Deno ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Edge Computing with Cloudflare Workers & Deno öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Edge Computing with Cloudflare Workers & Deno, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Worker Ortamını Kurma” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Edge Computing with Cloudflare Workers & Deno dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Edge Computing with Cloudflare Workers & Deno dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Worker Ortamını Kurma
  2. HTTP İsteklerini Ele Alma
  3. İlk Worker'ınızı Dağıtma
  4. Worker'larda Ortam Değişkenleri ve Gizli Bilgiler
← Edge Computing with Cloudflare Workers & Deno Sayfasına Dön