Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
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.
@ditojs/router
Advanced tools
Dito.js Router – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js
Dito.js is a declarative and modern web framework with a focus on API driven development, based on Koa.js, Objection.js and Vue.js
Released in 2018 under the MIT license, with support by https://lineto.com/
Dito.js Router is a high performance, tree-based, framework agnostic HTTP router, based on trek-router, which in turn is inspired by Echo's Router.
The router relies on a tree structure which makes heavy use of common prefixes, essentially a prefix tree.
import Koa from 'koa'
import Router from '@ditojs/router'
const app = new Koa()
const router = new Router()
// static route
router.get('/folders/files/bolt.gif', ctx => {
ctx.body = `this ain't no GIF!`
})
// param route
router.get('/users/:id', ctx => {
ctx.body = `requesting user ${ctx.params.id}`
})
// match-any route
router.get('/books/*', ctx => {
ctx.body = `sub-route: ${ctx.params['*']}`
})
// Handler found
let { handler, params } = router.find('get', '/users/233')
console.log(handler) // ctx => { ... }
// Entry not Found
let { handler, params } = router.find('get', '/photos/233')
console.log(handler) // null
// Install router middleware
app.use(async (ctx, next) => {
const { method, path } = ctx
const result = router.find(method, path)
const { handler, params } = result
if (handler) {
ctx.params = params || {}
return handler(ctx, next)
} else {
try {
await next()
} finally {
if (ctx.body === undefined && ctx.status === 404) {
ctx.status = result.status || 404
if (ctx.status !== 404 && result.allowed) {
ctx.set('Allow', result.allowed.join(', '))
}
}
}
}
})
app.listen(4040, () => console.log('Koa app listening on 4040'))
FAQs
Dito.js Router – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js
The npm package @ditojs/router receives a total of 145 weekly downloads. As such, @ditojs/router popularity was classified as not popular.
We found that @ditojs/router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.