1.1.103 • Published 5 years ago
cf-router v1.1.103
cf-router
A simple module for easily processing incoming requests to Cloudflare Workers.
This module is super-easy to use, and it's plug-and-play. Literally. All you have to do to start is to tell the module when you want to process a request, and it will handle everything for you.
In order to tell the module when it should process a request (or more specifically ,telling the router):
const { Router } = require("cf-router");
const router = new Router();
const apiRouter = new Router();
// Connecting routers
router.use("/api", apiRouter);
// Setting up paths
router.get("/", (req, res) => res.text("Hello, world!"));
apiRouter.get("/", (req, res) => res.text("Welcome to the API!"));
apiRouter.get("/welcome/:name", (req, res) => res.text(`Welcome, ${req.params.name}`));
// Listening for requests
addEventListener("fetch", event => {
event.respondWith(router.serve(event.request));
});
1.1.103
5 years ago
1.1.102
5 years ago
1.1.101
5 years ago
1.1.0
5 years ago
1.0.14
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago