restt

0.1.10 • Public • Published

Install Size Vulnerabilities Downloads Licence


Restt is a powerful framework for creating fast and reliable edge worker services.

Crafted for people who love fast development cycles, quality code, security, all while maintaining flexiblity of design.

Perfect for building anything from MVPs, to large entreprise applications, to development exercises in the classroom.

Benefits

Enjoy all of these amazing features with Restt

Safe and secure code

Built with zero* package dependencies to ensure your services are safe and secure from any vulnerabilities

Simple external service integration

Easily connect external API services you use like Stripe with Providers

Code flexibility

Shape your code the way you like it with few rules and restrictions

And even more with Restt-CLI

Serve your workers locally

Testing your edge workers services is easily served to you locally with Cloudworker

Auto-compilation and hot-reloading

Automatically recompile and reload your edge worker services on any changes when developing for testing in an instant ‍

Intelligent debugging tools

No more ugly stack traces - enjoy intelligently highlighted error code segments in your terminal ‍

Rapid production distribution

Distribute your edge worker services to people all around the globe instantly with Cloudflare Workers

Overview

Installation

Restt is available through the npm registry:

$ npm install restt

Restt-CLI is highly recommended alongside Restt and is also available through the npm registry:

$ npm install -g restt-cli

Usage

Creating a simple hello world service with Restt is as easy as the following:

helloworld-service.js
// 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
  origin: 'https://yourdomain.io',
  
  // Define the list of resources
  resources: [
    
    // Bind a resource to the service
    new Resource({
 
      // Define the endpoint (https://yourdomain.io/helloworld)
      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
app.use(helloworld);

If you're using Restt-CLI (and you're all configured) you can now deploy your services locally:

$ restt serve helloworld-service.js

Once served with Restt-CLI you can test your service - let's connect to our resource using curl:

$ curl http://localhost:3000/yourdomain.io/helloworld

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

{
  "message""helloworld!"
}

Now you're ready to deploy for production with Restt-CLI:

$ restt deploy helloworld-service.js

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

You can check a more detailed overview of the above in the hello world example repository.

Check out the store example repository which includes Stripe and Cloudflare WorkersKV.

API Documentation

Check out the documentation

Supporting

Restt is generously supported month to month by these amazing people, teams and organisations!

If you appreciate Restt and would like to regularly support the maintenance of it, please consider becoming a supporter, partner or sponsor.

One-time donations can also be made through PayPal.

Contributing

Please feel free to implement any features by submitting a pull request.

Alternatively, you also can submit a feature request.

All contributions are greatly appreciated!

License

MIT

Copyright (c) 2019-present, Daniel Larkin

Package Sidebar

Install

npm i restt

Homepage

restt.io

Weekly Downloads

1

Version

0.1.10

License

MIT

Unpacked Size

38.6 kB

Total Files

15

Last publish

Collaborators

  • danzlarkin