
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@ind.ie/web-routes-from-files
Advanced tools
Recursively traverses a given directory structure and uses convention to create a list of web route objects that map url paths to JavaScript callback files.
Recursively traverses a given directory structure and uses convention to create a list of web route objects that map url paths to JavaScript callback files.
npm i @ind.ie/web-routes-from-files
const getRoutes = require ('web-routes-from-files')
const routes = getRoutes('.')
routes.forEach(route => {
console.log(`${route.path}: ${route.callback}`)
})
Given the following directory structure:
.routes
├─── index.js
├─── my-folder
│ ├── index.js
│ └── other.js
└─── neat.js
And the following invocation:
const getRoutes = require ('web-routes-from-files')
const routes = getRoutes('.routes')
You will get the following data structure:
[
{ path: '/', file: '.routes/index.js' },
{ path: '/my-folder', file: '.routes/my-folder/index.js' },
{ path: '/my-folder/other', file: '.routes/my-folder/other.js' },
{ path: '/neat', file: '.routes/neat.js' }
]
Which, for example, you could pass to an Express app:
const express = require('express')
const getRoutes = require ('web-routes-from-files')
const app = express()
const routes = getRoutes('.routes')
routes.forEach(route => {
app.get(route.path, require(route.callback))
})
app.listen(8080, () => console.log('Server running on http://localhost:8080'))
Your routes should export standard middleware-style functions. e.g.,
function route (request, response, next) {
response.end('Hello, world!')
}
module.exports = route
Note: The module will ignore node_modules
folders and any folder within the root folder being traversed that begins with a dot (i.e., any hidden folder).
Copyright: ⓒ 2019 Aral Balkan. Licensed under AGPLv3 or later.
FAQs
Recursively traverses a given directory structure and uses convention to create a list of web route objects that map url paths to JavaScript callback files.
We found that @ind.ie/web-routes-from-files 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
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.