Sidra offers you many decorators for you to use with the Cloudflare Workers.
TypeScript definitions are built in.
- Run
or
$ npm install sidra
$ yarn add sidra
https://barbarbar338.github.io/sidra/
See https://github.com/barbarbar338/sidra-template
import { type APIRes, Controller, Get, Handle, HTTPStatus } from "sidra";
@Controller()
class MyController {
@Get()
get(): APIRes<string> {
return {
data: "Hello World",
message: "Hello World",
statusCode: HTTPStatus.OK,
};
}
}
const handler = Handle([MyController]);
addEventListener("fetch", (event) => {
event.respondWith(handler(event.request));
});