Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
express-enrouten
Advanced tools
Route configuration middleware for expressjs.
app.use(enrouten(options))
var express = require('express'),
enrouten = require('express-enrouten');
var app = express();
app.use(enrouten({ ... });
#### enrouten(app).withRoutes(options)
var express = require('express'),
enrouten = require('express-enrouten');
// Legacy API - do not use
//var app = express();
//enrouten(app).withRoutes({ ... });
express-enrouten supports routes via configuration and convention.
app.use(enrouten({
method: 'get',
path: '/foo',
handler: function (req, res) {
// ...
}
}]
});
directory
(optional) - String or array of path segments. Specify a directory to have enrouten scan all files recursively
to find files that match the controller-spec API.app.use(enrouten({
directory: 'controllers'
});
routes
(optional) An array of route definition objects. Each definition must have a path
and handler
property and
can have an optional method
property (method
defaults to 'GET').app.use(enrouten({
routes: [
{ path: '/', method: 'GET', handler: require('./controllers/index') },
{ path: '/foo', method: 'GET', handler: require('./controllers/foo') }
]
});
index
(optional, overrides directory
and disables scanning) - String path or array of path segments indicating
the file to load which acts as the route 'index' of the application.// index.js
module.exports = function (app) {
app.get('/', index);
app.get('/account', passport.protect, account);
// etc...
};
A 'controller' is defined as any javascript file (extension of .js
) which exports a function that accepts a single argument.
NOTE: Any file in the directory tree that matches the API will be invoked/initialized with the express application object.
// Good :)
// controllers/controller.js
module.exports = function (app) {
app.get('/', function (req, res) {
// ...
});
};
// Bad :(
// Function does not get returned when `require`-ed, use `module.exports`
exports = function (app) {
// ...
};
// Bad :(
// controllers/other-file-in-same-controller-directory.js
modules.exports = function (config) {
// `config` will be the express application
// ...
};
// Acceptable :)
// controllers/config.json - A non-js file (ignored)
// controllers/README.txt - A non-js file (ignored)
// controllers/util.js - A js file that has a different API than the spec (ignored)
module.exports = {
importantHelper: function () {
}
};
v0.2.0 - 20140127
Bugs
Features
FAQs
An express route initialization and configuration module.
The npm package express-enrouten receives a total of 2,929 weekly downloads. As such, express-enrouten popularity was classified as popular.
We found that express-enrouten demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.