Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
fast-koa-router
Advanced tools
npm install fast-koa-router
const routes = {
get: {
'/path': async function(ctx, next) {
ctx.body = 'ok';
},
'/nested': {
'/path': async function(ctx, next) {},
'/path/:id': async function(ctx, next) {}
}
},
post: {
'/path': async function(ctx, next) {}
},
policy: {
'/path': async function(ctx, next) {},
'/nested': {
'/path': async function(ctx, next) {},
'/path/:id': async function(ctx, next) {}
}
}
};
// or
const routes = {
'/path': {
get: async function(ctx, next) {
ctx.body = 'ok';
},
post: async function(ctx, next) {},
policy: async function(ctx, next) {}
},
'/nested': {
'/path': { get: async function(ctx, next) {}, policy: async function(ctx, next) {} },
'/path/:id': { get: async function(ctx, next) {}, policy: async function(ctx, next) {} }
}
};
// or
const routes = {
get: {
'/path': async function(ctx, next) {},
'/nested/path': async function(ctx, next) {},
'/nested/path/:id': async function(ctx, next) {}
},
post: {
'/path': async function(ctx, next) {}
},
policy: {
'/path': async function(ctx, next) {},
'/nested/path': async function(ctx, next) {},
'/nested/path/:id': async function(ctx, next) {}
}
};
Supports
methods
const Koa = require('koa');
const app = new Koa();
const { router } = require('fast-koa-router');
app.use(router(routes));
app.listen(8080);
Policies are used for authentication and authorization. They must call next in order for the actual route to be executed.
The path matching is pretty simple. Unlike other middlewares not all routes are checked so performance does not degrade with routes size. However complex regex matching is not supported.
FAQs
It uses a simple routes json object. Routes order does not matter. Performance does not degrade with routes length.
We found that fast-koa-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
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.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.