
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
larvitrouter
Advanced tools
Route an URL to a controller, template and/or a static file.
Auto resolves files like so:
This behaviour can be changed with customized options.
npm i larvitrouter
All options passed here are optional and the given ones are the default that will be used if they are omitted.
Paths are relative to application root as first priority. If nothing is found there, all modules will be tested as relative to this path to try to find a matching file. The modules are searched in the order given in package.json dependencies.
Simple, use default options:
const Router = require('larvitrouter'),
router = new Router();
Use custom options (the defaults are used in this example):
const LUtils = require('larvitutils');
const lUtils = new lUtils();
const Router = require('larvitrouter');
const router = new Router({
'basePath': process.cwd(),
'cacheMax': 1000
'paths': {
'controller': {
'path': 'controllers',
'exts': 'js'
},
'static': {
'path': 'public',
'exts': false // Match all
},
'template': {
'path': 'public/templates',
'exts': ['tmpl', 'tmp', 'ejs', 'pug']
}
},
'log': new lUtils.Log(),
'routes': [{
'regex': '^/$',
'controllerPath': 'default.js',
'templatePath': 'default.tmpl'
}]
});
const Router = require('larvitrouter');
const router = new Router();
const http = require('http');
http.createServer(function(req, res) {
router.resolve(req.url, function(err, result) {
if (err) throw err;
// A static file was found
if (result.staticFilename !== undefined) {
console.log('static path: ' + result.staticPath);
console.log('static full path: ' + result.staticFullPath);
}
// A controller was found
if (result.controllerPath) {
console.log('controller path: ' + result.controllerPath);
console.log('controller full path: ' + result.controllerFullPath);
}
// A template was found
if (result.templatePath) {
console.log('template path: ' + result.templatePath);
console.log('template full path: ' + result.templateFullPath);
}
res.end('Resolved stuff, see console output for details');
})
}).listen(8001);
FAQs
URL router
We found that larvitrouter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.