Custom Routers - tsgrp/HPI GitHub Wiki

For clients with specific routes in HPI, rather then overriding the main.js file (responsible for loading all Backbone.Routers in HPI), a project can add and remove routers by overriding configuredRouters.js in their project directory.

To override the configured routers, create a copy of core configuredRouters.js in your project directory:

project/{{ your project }}/app/configuredrouters.js

Add your router (clientrouter in this example) as a Require.js module like the example below:

define([
    'app',
    "router",
    "adminrouter",
    "searchrouter",
    "dashboardrouter",
    "folderbrowserrouter",
    "indexerrouter",
    "modules/wizard/activeformrouter",
    "detailviewrouter",
    "oauthrouter",
    "userpreferencesrouter",
    "clientrouter"
], function(app, Router, AdminRouter, 
    SearchRouter, DashboardRouter, FolderBrowserRouter, 
    IndexerRouter, ActiveFormRouter, DetailViewRouter, 
    OAuthRouter, UserPreferencesRouter, ClientRouter){
    var configuredRouters = {
        main : new Router(),
                admin : new AdminRouter(),
                search : new SearchRouter(),
                dashboard : new DashboardRouter(),
                folderbrowser : new FolderBrowserRouter(),
                indexer : new IndexerRouter(),
                activeform : new ActiveFormRouter(),
                detailView : new DetailViewRouter(),
                oauth: new OAuthRouter(),
                userpreferences: new UserPreferencesRouter(),
                myclient: new ClientRouter()
    };
    
    return configuredRouters;
});

Your custom router is now available without overriding any other files.