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.
Built with zero* package dependencies to ensure your services are safe and secure from any vulnerabilities
Easily connect external API services you use like Stripe with Providers
Shape your code the way you like it with few rules and restrictions
Testing your edge workers services is easily served to you locally with Cloudworker
Automatically recompile and reload your edge worker services on any changes when developing for testing in an instant
No more ugly stack traces - enjoy intelligently highlighted error code segments in your terminal
Distribute your edge worker services to people all around the globe instantly with Cloudflare Workers
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
Creating a simple hello world service with Restt is as easy as the following:
// 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.
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.
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!
Copyright (c) 2019-present, Daniel Larkin