npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

restt

v0.1.10

Published

create powerful restful services with edge workers

Downloads

22

Readme


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