
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
express-dynamic-router
Advanced tools
author : Yuki Takei(MikeTOKYO)
email : yuki@miketokyo.com
##Overseas express-dynamic-router provide you the auto routing system for express.
You don't need to write routing codes written in express docs
app.get("hellow/world", hellow.world);
app.post("hellow/world", hellow.world);
app.put("hellow/world", hellow.world);
app.delete("hellow/world", hellow.world);
You only have to write easy code like bellow
require('express-dynamic-router')
.index(require('routes/index').index)
.register(app);
##Instalation
npm install express-dynamic-router
##Usage
express/app.js
app.configure('development', function(){
app.use(express.errorHandler());
});
//use express-dynamic-router
require('express-dynamic-router')
.index(require('routes/index').index) // Set action for index
.register(app);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
If you change routes dir, You only have to add setRoutesDir(path-your-route-dir) on method chain
require('express-dynamic-router')
.index(require('routes/index').index)
.setRoutesDir("path-to-your-routes")
.register(app);
##Api Reference
Register all routes in your routes dir except for actions which are ignored.
dynamicRouter.register(object expressApp)
Set path to your routes dir (First, dynamic-router browse express/routes, if you don't use this method.)
dynamicRouter.setRoutesDir(string path-to-your-custome-routes-dir)
Get your routes dir string.
dynamicRouter.getRoutesDir()
Set index action (accessible http://your-domain.com/)
dynamicRouter.index(function indexAction)
Register only routes which are given arguments.
dynamicRouter.applyOnly(['routes1', '....'])
dynamicRouter
.applyOnly(['user', 'account'])
})
.register('app);
# GET /user/index -> 200 OK
# POST /account/save -> 201 Created
# GET /mypage/index -> 404 Not Found
Set ignore actions which you not want to register.
dynamicRouter.ignore(object ignoreAction)
dynamicRouter
.ignore({
'/*' : ['hogehoge', 'fugafuga'], // apply ignoreing to all routes.
'user' : ['initialize', 'beforeRenderHook'] // apply ignoreing to user.
})
.register('app);
# GET /user/hogehoge -> 404 Not Found
# POST /account/fugafuga -> 404 Not Found
# GET /user/initialize -> 404 Not Found
# GET /user/list -> 200 OK
##Runing tests
mocha test/router.js
##License MIT
FAQs
provide dynamic routing system for express
We found that express-dynamic-router 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.