
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.
@entando/router
Advanced tools
this package is currently deprecated and no longer supported
This is a router used with redux in the entando projects.
run npm i @entando/router
{
"mode": "browser", // history mode, can be 'hash' or 'browser'
"pathPrefix": "my-web-context",
"routes": [
{ "name": "homePage", "path": "/" },
{ "name": "about", "path": "/about" },
{ "name": "user", "path": "/user/:id" },
],
"notFoundRoute": { "name": "notFound", "path": "/404" }
}
The path can contain parameters, following the path-to-regexp syntax. Some example:
/user/:id
/user/616 ⇒ { route: 'user', params: { id: '616'} }/user ⇒ no match/pictures/:viewMode?
/pictures/list ⇒ { route: 'pictures', params: { viewMode: 'list'} }/pictures ⇒ { route: 'pictures', params: { viewMode: ''} }Use them to restrict a parameter to match a regular expression. E.g. to have the id parameter to be a sequence of numbers:
/user/:id(\\d+) (Note the double-escaped backslashes)
/user/12 ⇒ { route: 'user', params: { id: '12'} }/user/abc ⇒ no matchParameters with no name, the params key will be their position index. E.g.:
/coords/(\\d+)/(\\d+)
/coords/12/34 ⇒ { route: 'coords', params: { '0': '12', '1': '34' } }Use * for 0 or more repetitions
/users/:ids*
/users/john/jack/jim ⇒ { route: 'users', params: { 'ids': 'john/jack/jim' } }/users ⇒ { route: 'users', params: { } }Use + for 1 or more repetitions
/groupcall/:users+
/groupcall/john/jack/jim ⇒ { route: 'groupcall', params: { 'users': 'john/jack/jim' } }/groupcall ⇒ no matchimport { combineReducers } from 'redux';
import { routerReducer as router } from '@entando/router';
export default combineReducers({
router, // the default key is 'router'
});
The resulting state will be:
{
router: {
location: {...},
route: '...',
params: {...},
searchParams: {...},
}
}
Note that the state key must be router. If for any reason you need to mount the router
state to a different path, you must use the setRouterSelector function, passing a selector
to the router state. E.g.
import { combineReducers } from 'redux';
import { routerReducer, setRouterSelector } from '@entando/router';
// needed to set up the custom router key(s)
setRouterSelector(state => state.one.two);
export default combineReducers({
one: combineReducers({
two: routerReducer,
}),
});
The resulting state will be:
{
one: {
two: {
location: {...},
route: '...',
params: {...},
searchParams: {...},
}
}
}
The routerConfig function needs the Redux store and the JSON routes config object. E.g.:
import { createStore } from 'redux';
import rootReducer from 'app/reducer';
import { routerConfig } from '@entando/router';
// this can be defined elsewhere and imported
const routerConfig = {
routes: [
{ name: 'home', path: '/' },
],
notFoundRoute: { name: 'notFound', path: '/not-found' },
};
const store = createStore(rootReducer);
routerConfig(store, routerConfig);
Just create a React Component taking the route via props, and connect it to the state:
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getRoute } from '@entando/router';
import showcase from 'react-showcase';
import LoginPage from 'ui/login/LoginPage';
import LoginForm from 'ui/login/LoginForm';
const MyRouter = ({ route }) => {
switch (id) {
case 'home': return <MyHomePage />;
case 'about': return <MyAboutPage />;
default: return <MyNotFoundPage />;
}
};
MyRouter.propTypes = {
route: PropTypes.string.isRequired,
};
const mapStateToProps = state => ({
route: getRoute(state),
});
export default connect(mapStateToProps, null)(MyRouter);
Use Link component to create internal links. Usage:
// sample router config JSON:
const config = {
routes: [
{ name: 'user', path: '/user/:id' }
],
};
// sample Component using Link
import { Link } from '@entando/router';
// ... into the component JSX ...
// resulting URL: /user/72
<Link
route="user"
params={{ id: '72' }}
/>
// resulting URL: /user/72?view=profile
<Link
route="user"
params={{ id: '72' }}
searchParams={{ view: 'profile' }}
/>
To redirect to a route programmatically (e.g. in response to an authentication error), the
gotoRoute function must be used. E.g.:
import { gotoRoute } from '@entando/router';
// ... other code ...
// resulting URL: /user/72
gotoRoute('user', { id: '72' });
// resulting URL: /user/72?view=profile
gotoRoute('user', { id: '72' }, { view: 'profile' });
FAQs
router used with redux for entando frontend applications
We found that @entando/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.

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.