export const LIST_ROUTE = '' ; export const CREATE_ROUTE = 'create' ; export const EDIT_ROUTE = ':id/edit' ; export const SHOW_ROUTE = ':id' ; export abstract class AbstractRouter { protected static resource = '' ; public static getIdFromIRI ( iri ) { return iri . split ( '/' ) . pop ( ) ; } public static redirectTo ( params ) { return `/${ this . resource }${ params }` ; } public static redirectToEdit ( id ) { return this . redirectTo ( `/${ EDIT_ROUTE . replace ( ':id' , id ) }` ) ; } public static redirectToEditFromIRI ( id ) { return this . redirectToEdit ( this . getIdFromIRI ( id ) ) ; } public static redirectToCreate ( ) { return this . redirectTo ( `/${ CREATE_ROUTE }` ) ; } public static redirectToShow ( id ) { return this . redirectTo ( `/${ SHOW_ROUTE . replace ( ':id' , id ) }` ) ; } public static redirectToShowFromIRI ( id ) { return this . redirectToShow ( id . split ( '/' ) . pop ( ) ) ; } public static redirectToList ( ) { return this . redirectTo ( LIST_ROUTE ) ; } public static redirectToListFromIRI ( ) { return this . redirectToList ( ) ; } }