Skip to content
A simple "hello world" service created with Restt
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A simple "hello world" edge worker service built with Restt and Restt-CLI.

Getting started

Once you've cloned or downloaded this repository you'll want to open terminal in the project root and install the packages:

$ npm install

You should successfully have installed the required dependencies now.

Setting up your project

Open up the src directory and you should find a file named src/helloworld-service.js which looks like this:

// Import the required classes from Restt
import { Restt, Service, Resource, Response } from 'restt';

// Create a hello world service
const helloworld = new Service({

  // Define the origin of the service (change '' to your domain)
  origin: '',
  // Define the list of resources
  resources: [
    // Bind a resource to the service
    new Resource({

      // Define the endpoint (
      endpoint: '/helloworld',

      // Define the resource protocol
      method: 'GET',
      // Define the response of the resource
      response() {

        // Create a response to send to the client
        return new Response({

          // Define the body of the response
          body: {
            message: 'hello world!'

// Create the Restt application
const app = new Restt();

// Bind the service to the application

Open this file in VSCode or your code editor of choice.

You'll see the origin is being set to

Replace with your domain name (e.g. you'll be deploying to production with.

Serving and testing your services locally

Now that you've finished setting up your project you can proceed to serving your edge worker services locally with Restt-CLI:

$ restt serve src/helloworld-service.js

Once served you can test your edge worker services are working correctly - let's connect to our resource using curl (you'll need to replace for your domain again):

$ curl http://localhost:3000/

If everything is working correctly then curl should output the following:

  "message": "helloworld!"

Distributing your service with Cloudflare Workers

Please ensure that configured cloudflare in your restt.config.json you have also registered for Cloudflare Workers on your Cloudflare account.

You're now ready to deploy your edge worker services in production with Cloudflare Workers using Restt-CLI:

$ restt deploy src/helloworld-service.js

Congratulations - you've succesfully built and shipped your services to the edge using Cloudflare Workers and Restt!

Check out the store example repository which also includes a Provider using Stripe and WorkersKV.

You can also check out the full Restt Documentation and Restt-CLI Documentation.

You can’t perform that action at this time.