Skip to content
 
 

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM JavaScript Style Guide Badges Badges Badges Badges Badges Badges

Make route path

Make your router paths type safe and great!

npm install make-route-path --save
yard add make-route-path
const productUrl = makeRoutePath<
  {
    productId: number;
    fromSection: string;
    productSection: 'images' | 'description';
  },
  {
    someQueryParam?: string;
    someAnotherQueryParam?: string;
  }
>('/catalog/:productId/:fromSection/:productSection');

// Make url with params
productUrl({ productId: '10', fromSection: 'a123', productSection: 'images' });
// '/catalog/10/a123/images'

// Make url with query params
productUrl({
    productId: '10',
    fromSection: 'a123',
    productSection: 'images'
}, {
    someQueryParam: "test";
    someAnotherQueryParam: "test";
});
// '/catalog/10/a123/images?someQueryParam=test&someAnotherQueryParam=test'

// Returns real path
productUrl.PATH;
// '/catalog/:productId/:fromSection/:productSection'
//  usable for example react-router routes

About

🧁 Make route paths sweet again! Type safe route paths for your lovely router

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages