itty-router
It's an itty bitty router. That means small. It's tiny. For reals.
Installation
yarn add itty-router
or if you've been transported back to 2017...
npm install itty-router
Our Goals
Example
import { Router } from 'itty-router'
const router = new Router()
router.get('/todos', async () => new Response('list of todos'))
router.get('/todos/:id', async ({ params }) => new Response(`details for todo #${params.id}`))
router.post('/todos', async () => new Response('created a new todo!'))
router.get('/search', async ({ query }) => new Response(JSON.stringify(query)) ?q=foo ---> { q: 'foo' }
addEventListener('fetch', router.handle(event))
Testing & Contributing
- fork repo
- add code
- run tests (and add your own)
yarn test
- submit PR
- profit