
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@jpbberry/load-routes
Advanced tools
@jpbberry/load-routes
is a package dedicated to easily, powerfully, and simply dynamically loading routes over folders and sub-folders. Routes are decides by the folders they're in, and the name of the files.
(This also has support for typescript, just replace all module.exports = ...
with exports default ...
)
Install via npm i @jpbberry/load-routes
The package exports LoadRoutes
with the paramaters LoadRoutes(app, directory, bind?)
The express app or router to load the directory into
A full path directory to load all routes in
An optional variable to bind all the routers function by, making it this
index.js
const { LoadRoutes } = require('@jpbberry/load-routes')
const Path = require('path')
const Express = require('express')
const app = Express()
LoadRoutes(app, Path.resolve(__dirname, './routes'))
app.listen(3000)
And in your /routes folder, put your routes!
routes/foo.js
module.exports = function (r) {
r.get('/', (req, res) => {
res.json({
bar: true
})
})
r.get('/not', (req, res) => {
res.json({
bar: false
})
})
}
When loaded, this will now make ip:3000/foo and /foo/not with these GETs!
Sometimes your middlewares and base / files can get pretty big, so you can add an index.js which will let you listen to the inside of the sub-folder, for example:
routes/hello/index.js
module.exports = function (r) {
r.get('/', (req, res) => {
res.json({
hello: 'world'
})
})
}
And then you can have your non-cluttered routes in side of the hello
folder
routes/hello/test.js
module.exports = function (r) {
r.get('/', (req, res) => {
res.json({
test: true
})
})
}
And this will now listen on ip:3000/hello and /hello/test
You can pass an object which will be the same everywhere to the third paramater bind
. This is extremely useful in a client centered program. It will define the this
in every router. For example
index.js
const Client = {
foo: 'bar'
}
LoadRoutes(app, dir, Client)
Now Client
will be available as this
Also note that () => {} cannot access this
, you must use function ()
to get it
routes/foo.js
module.exports = function (r) {
r.get('/', (req, res) => {
res.json({
foo: this.foo // "bar"
})
})
}
FAQs
A package dedicated to loading routes dynamically
We found that @jpbberry/load-routes 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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.