1.1.1 • Published 11 months ago

joyrouter v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

JoyRouter

npm version code style: prettier

JoyRouter is a router designed for cloudflare workers.

It has many functionalities, such as:

  • Swagger UI documentation
  • Automatic OPTIONS request handling
  • Middleware
  • JSON responses
  • Error responses
  • And more!

To access swagger ui, go to the url of your worker with the path '/docs'. This page can be disabled by setting the internalRoutes option to false.

It is highly recommended to use the jrdoc tag along with Jrdoc Highlighting for VSCode. This will ease the process of creating your routes.

Documentation

Documentation can be found here.

Installation

npm i joyrouter

Usage

import { JoyRouter } from "joyrouter";

const router = new JoyRouter();

function post_path(request: Request) {
    return new Response("Hello world!", { status: 200 });
}

function get_path(request: Request, returnable: string) {
    /*jrdoc*/`
    An example function that returns the query parameter.
    @param where:query type:string name:returnable | The parameter to return
    `;

    return new Response(returnable, { status: 200 });
}

router
    .json("GET", "/", { detail: "Hello world!" }, 200)
    .post("/", post_path);
    .get

export default {
    async fetch(request: Request) {
        return await router.handle(req);
    },
};
1.1.1

11 months ago

1.1.0

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago