1.0.1 • Published 4 years ago

router-basic v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

A small package for building custom multipurpose routers, similar to express.js.

Quick Start

import { router } from "router-basic"

const testRouter = router({
    matches: (str, req) => str === req.endpoint,
    response: {
        log: console.log,
    },
})

const app = testRouter({})

app.handle("hello-world", (req, res) => {
    res.log("Found the hello world endpoint!")
})

app.handle("goodbye-world", (req, res) => {
    res.log("Looks like we're leaving, huh...")
})

app.emit({ endpoint: "hello-world" })
// Found the hello world endpoint!

app.emit({ endpoint: "goodbye-world" })
// Looks like we're leaving, huh...