Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
itty-router
Advanced tools
A tiny, zero-dependency router, designed to make beautiful APIs in any environment.
Itty aims to be the world's smallest (~440 bytes), feature-rich JavaScript router, enabling beautiful API code with a near-zero bundlesize. Designed originally for Cloudflare Workers, itty can be used in browsers, Service Workers, edge functions, or standalone runtimes like Node, Bun, etc.!
Complete docs/API are available at itty.dev, or join our Discord channel to chat!
npm install itty-router@next
import {
error, // creates error responses
json, // creates JSON responses
Router, // the ~440 byte router itself
withParams, // middleware: puts params directly on the Request
} from 'itty-router'
import { todos } from './external/todos'
// create a new Router
const router = Router()
router
// add some middleware upstream on all routes
.all('*', withParams)
// GET list of todos
.get('/todos', () => todos)
// GET single todo, by ID
.get('/todos/:id',
({ id }) => todos.getById(id) || error(404, 'That todo was not found')
)
// 404 for everything else
.all('*', () => error(404))
// Example: Cloudflare Worker module syntax
export default {
fetch: (request, ...args) => router
.handle(request, ...args)
.then(json) // send as JSON
.catch(error) // catch errors
}
Have a question? Suggestion? Complaint? Want to send me a gift basket?
Join us on Discord!
yarn
yarn dev
yarn verify
These folks are the real heroes, making open source the powerhouse that it is! Help out and get your name added to this list! <3
FAQs
A tiny, zero-dependency router, designed to make beautiful APIs in any environment.
We found that itty-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.