
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@lebretr/koa-router-enrouten
Advanced tools
An koa route initialization and configuration module.
Route configuration middleware for koa-router.
enrouten(options, router))
const Koa = require('koa')
, app = new Koa()
, Router = require('koa-router')
, router = new Router()
, enrouten = require('@lebretr/koa-router-enrouten');
enrouten({
directory: './controllers'
},router);
app.use(router.routes())
.use(router.allowedMethods());
...
// or app.use('/foo', enrouten({ ... }));
The directory
configuration option (optional) is the path to a directory.
Specify a directory to have enrouten scan all files recursively to find files
that match the controller-spec API. With this API, the directory structure
dictates the paths at which handlers will be mounted.
controllers
|-user
|-create.js
|-list.js
// create.js
module.exports = function (router) {
router.post('/', function (ctx) {
ctx.status=200;
ctx.body('ok');
});
};
enrouten({
directory: './controllers'
},router);
Routes are now:
/user/create
/user/list
The index
configuration option (optional) is the path to the single file to
load (which acts as the route 'index' of the application).
enrouten({
index: 'routes/'
},router);
// index.js
module.exports = function (router) {
router.get('/', index);
router.all(passport.protect).get('/account', account);
// etc...
};
A 'controller' is defined as any require
-able file which exports a function
that accepts a single argument. Any files with an extension of .js
(or .coffee
if CoffeeScript is registered) will be loaded and if it exports a function that
accepts a single argument then this function will be called. NOTE: Any file in
the directory tree that matches the API will be invoked/initialized with the
koa-router object.
// Good :)
// controllers/controller.js
module.exports = function (router) {
router.get('/', function (ctx) {
// ...
});
};
// Bad :(
// Function does not get returned when `require`-ed, use `module.exports`
exports = function (router) {
// ...
};
// Bad :(
// controllers/other-file-in-same-controller-directory.js
modules.exports = function (config) {
// `config` will be an koa-router
// ...
};
## Linting
```bash
$ npm run-script lint
$ npm test
$ npm run-script cover && open coverage/lcov-report/index.html
FAQs
An koa route initialization and configuration module.
The npm package @lebretr/koa-router-enrouten receives a total of 0 weekly downloads. As such, @lebretr/koa-router-enrouten popularity was classified as not popular.
We found that @lebretr/koa-router-enrouten 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.