Skip to content

riceyrolling/tight-scene-fe5d

Repository files navigation

Cloudflare Workers: A Comprehensive Guide 🚀

This repository contains the example code for the Medium article: "The Ultimate Guide to Cloudflare Workers". In this article, we explore the capabilities of Cloudflare Workers, an edge computing service that allows you to run your code closer to the user.

TThe application has two routes:

  • /todo - returns a JSON todo list from an API source.
  • /media - returns a random image from an API source.

Table of Contents

Features

  • Edge Computing with Cloudflare Workers
  • Routing HTTP requests
  • Fetching media from external APIs
  • Cron-triggered events
  • Enhanced security and low-latency

Prerequisites

Getting Started

  1. Clone the Repository

    git clone https://github.com/riceyrolling/tight-scene-fe5d.git
  2. Navigate to the directory

    cd tight-scene-fe5d
  3. Install Dependencies

    npm install 
  4. Authenticate Wrangler

    wrangler login
  5. Deploy to Cloudflare

    wrangler deploy

File Structure

  • index.js: Entry point for the worker code.
  • router.js: Contains routing logic for incoming HTTP requests.
  • routes/: Directory containing individual route handlers.
    • todoRoute.js: Route handler for /todo path.
    • mediaRoute.js: Route handler for /media path.

Usage

Make an HTTP request to your deployed Cloudflare Worker:

  • To get a TODO item:

    GET https://your-cloudflare-worker.your-subdomain.workers.dev/todo
    
  • To get a random image:

    GET https://your-cloudflare-worker.your-subdomain.workers.dev/media
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages