I am trying to figure how best to handle two types of bad routes.
- One is a type check. Since i know my ID should be a numeric value
- Two is when they have put in a bad order number
For the type check is the best way to handle this to simply put in a check in javascript in the activate method on the order module and redirect to a not found module if it fails? OR is there some aurelia trick to on this to force it to be a unknown route or something...
Similarly on the bad order number if I do a fetch on the order and it returns no results do I just redirect as well?
Basically just wondering if that's best practice or is there a better way to handle this?
configureRouter(config: RouterConfiguration, router: Router) {
config.title = 'My Aurelia APP';
config.map([
{ route: ['', "orders"], name: 'orders', moduleId: 'orders', nav: true, title: 'List Of Cool Stuff' },
{ route: ':id', moduleId: 'order', name: 'Order Info' }]);
this.router = router;
config.mapUnknownRoutes('not-found');
}
orderViewModel - rather than querying an order number in the router, which isn't what it's designed for. - Tom