
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@bakeryjs/router
Advanced tools
Install library via npm:
$ npm install @bakeryjs/router
Create a new router:
const router = require('./router')();
// or (if it's needed to use different routers that will be isolated from each other)
const Router = require('./router');
const router = Router();
Configure route (endpoint) and it's handler:
router
.handle('/authors/:authorId/books', createBook)
.method('POST')
.provideReqRes(true)
.sendResponse(false);
Set handler for http server:
const server = http.createServer(router.handler);
(method) handle: (pattern: string, handler: function)
- register endpoint and it's handlerNOTE: use ':
' symbol to indicate a query parameter.
(property) handler: function
- get http handler(method) method(value: string)
- set HTTP method for route (GET
by default)(method) provideReqRes(value: boolean)
- provide req
and res
objects to handler function (false
by default)(method) sendResponse(value: boolean)
- send response with function return value (true
by default)NOTE: if it's needed to send custom response from hanlder the provideReqRes
should be true to get req
object and use it to prepare and send response.
Take a look on demo project.
FAQs
Node.js HTTP Router for handling requests and performing responses
We found that @bakeryjs/router demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.