
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
express-otto
Advanced tools
A lightning fast :zap: automatic router-registration solution for express applications.
A lightning fast :zap: automatic router-registration solution for express applications.
(Built with extensibility in mind)
Automatically crawls your project in order to register routers to your express application. You can use this on older express projects or newer ones. Create static routes if you prefer managing your routes with code or create dynamic routes if you prefer a more modern approach.
Dynamic routing has become more and more popular lately --- and with so many benefits, why wouldn't it be?
It has:
npm install express-otter
Given a project structure like so....
Dynamic routing uses the project structure to define router URLs.
root
├──dist
├──src
│ ├──middleware
│ ├──models
│ ├──routes <-------------- base path
│ │ └──pets
│ │ └──[pet].js <------ router
│ └──utils
└──tests
/** ./app.js */
import express from 'express'
import { registerRouters } from 'express-otter'
const app = express()
/** Register routers after initializing the app */
await registerRouters({
app,
path: ['./src/routes'] // Points to the routes directory
})
app.listen(3000, () => {
console.log('Server running at http://localhost:3000')
})
/** ./src/routes/pets/[pets].js */
import express from 'express'
import { generateURL } from 'express-otter'
/** Used to generate the URL when registering routes */
const url = generateURL()
// '/pets/:pets'
const router = express.Router()
/** Router will automatically be registered */
router.get(url, (req, res) => {
res.send('You have reached this endpoint!')
})
export default router
const response = await fetch('http://localhost:3000/pets/dog')
.then(response => response.text())
console.log(response)
// 'You have reached this endpoint!'
Static routing uses the code to defined router URLs.
root
├──dist
├──src
│ ├──middleware
│ ├──models
│ ├──routes <-------------- base path
│ │ └──cars.js <---------- router
│ └──utils
└──tests
/** ./app.js */
import express from 'express'
import { registerRouters } from 'express-otter'
const app = express()
/** Register routers after initializing the app */
await registerRouters({
app,
path: ['./src/routes'] // Points to the routes directory
})
app.listen(3000, () => {
console.log('Server running at http://localhost:3000')
})
/** ./src/routes/cars.js */
import express from 'express'
const router = express.Router()
/** Router will automatically be registered */
router.get('/cars/toyota/:model', (req, res) => {
res.send('You have reached this endpoint!')
})
export default router
const response = await fetch('http://localhost:3000/pets/dog')
.then(response => response.text())
console.log(response)
// 'You have reached this endpoint!'
| Property | Type | Default | Description |
|---|---|---|---|
| app | Express | An express app. | |
| path | string[] | Defines the base path(s) when looking for routers. | |
| slug_pattern | RegExp | /\[(.+)\]/g | A global pattern for capturing slugs in files/folders. |
| ignore_pattern | RegExp | /^_/ | A pattern for ignoring files/folders. |
| dry | boolean | false | Specifies whether to perform a dry run. |
| beforeRegister | function | A callback that is invoked right before registering a router. | |
| afterRegister | function | A callback that is invoked right after registering a router. |
To install dependencies:
bun install
To run:
bun run index.ts
This project was created using bun init in bun v0.6.12. Bun is a fast all-in-one JavaScript runtime.
FAQs
A lightning fast :zap: automatic router-registration solution for express applications.
We found that express-otto 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.