# cf-router

> A simple (yet powerful) Cloudflare Workers router

Latest version **1.1.103** (published 2020-05-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install cf-router
pnpm add cf-router
yarn add cf-router
bun add cf-router
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.103 |
| Published | 2020-05-09 |
| First published | 2020-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 50.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Visualizememe |
| Maintainers | scriptbased |

## Links

- npm: https://www.npmjs.com/package/cf-router
- Repository: https://github.com/ScriptersCF/node-cf-router
- Homepage: https://github.com/ScriptersCF/node-cf-router#readme
- Issues: https://github.com/ScriptersCF/node-cf-router/issues
- npm.io page: https://npm.io/package/cf-router

## Dependencies (2)

- [cookie](https://npm.io/package/cookie.md) ^0.4.1
- [url-pattern](https://npm.io/package/url-pattern.md) ^1.0.3

## Recent versions

- 1.1.103 (latest) — 2020-05-09
- 1.1.102 — 2020-05-07
- 1.1.101 — 2020-05-06
- 1.1.0 — 2020-05-06
- 1.0.14 — 2020-02-01
- 1.0.13 — 2020-02-01
- 1.0.12 — 2020-02-01
- 1.0.11 — 2020-01-28
- 1.0.10 — 2020-01-24
- 1.0.9 — 2020-01-19
- 1.0.8 — 2020-01-19
- 1.0.6 — 2020-01-19
- 1.0.5 — 2020-01-18
- 1.0.4 — 2020-01-11
- 1.0.3 — 2020-01-11
- … 3 more at https://npm.io/package/cf-router/versions

## README

## cf-router
A simple module for easily processing incoming requests to Cloudflare Workers.

----
<a href="https://npmjs.com/package/bloxy"><img src="https://img.shields.io/npm/v/cf-router.svg?maxAge=3600&style=flat-square" alt="NPM"></a>
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/97059473b41c44238c5698963065f47a)](https://www.codacy.com/manual/Visualizememe1/node-cf-router?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Visualizememe/node-cf-router&amp;utm_campaign=Badge_Grade)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FVisualizememe%2Fnode-cf-router.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FVisualizememe%2Fnode-cf-router?ref=badge_shield)

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*):
```JavaScript
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));
});

```


[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FVisualizememe%2Fnode-cf-router.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FVisualizememe%2Fnode-cf-router?ref=badge_large)

---
_Source: https://npm.io/package/cf-router · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
