Skip to content

An abstraction of express.js for broader use cases.

Notifications You must be signed in to change notification settings

andysham/router-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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...

About

An abstraction of express.js for broader use cases.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published