![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
glob-to-routes
Advanced tools
A simple utility for converting globs to route paths to be used with your routing system
A simple utility that converts a glob file selection to routes that can be used with any routing library.
npm install glob-to-routes
import globToRoutes from 'glob-to-routes'
const routes = await globToRoutes(baseDir, globPath, conversionFunction)
This library simply converts the results of a glob (default is **/*.{js,jsx}
) into an array of objects containing each file path, and its corresponding route string. As each routing library may vary, the default conversion function uses expressjs like syntax. Here is an example of setting up express routes from page files inside a /pages
folder.
const routes = await globToRoutes('./pages')
for (const { route, filePath } of routes) {
app.get(route, pageHandler(filePath))
}
In this case, pageHandler
would be a function that takes in a file path and returns a valid route function based on what the file does.
If you wish to perform custom conversions of paths to route strings, just provide a function that takes in a route path, and returns the relevant transformed string.
This library was built @wethrift.
FAQs
A simple utility for converting globs to route paths to be used with your routing system
The npm package glob-to-routes receives a total of 2 weekly downloads. As such, glob-to-routes popularity was classified as not popular.
We found that glob-to-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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.