GitXplorerGitXplorer
l

js-reverse

public
0 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
42f3191f70ee42371d5e8ef6c407251bcfbbf38e

eslintrc deleted

committed 6 years ago
Unverified
445f3fdeb4d13a037eeaf4fe76a18f079c48b98d

TODO deleted

committed 6 years ago
Unverified
525a09f41c523a0e29f5bfd83c739cb4461003d4

Query strings processing added

committed 6 years ago
Unverified
168df8d419b5a0fa7bde8d40e310ba73189f53ac

Changed url_constructor name to camelCase

committed 6 years ago
Unverified
398f5ca025e38a31f814c0560096fad339e1ab38

Merge branch 'master' of https://github.com/srgpdbd/js-reverse

committed 6 years ago
Unverified
ba19fed0e237170c3b810371b0d4ea03851202a6

Errors throwing for not registered urls. Closes #8

committed 6 years ago

README

The README file for this repository.

js-reverse

Allows to store urls in one place and get it everywhere you want. Just like in Django.

How to use

Install

yarn add js-reverse

Define urls in one place

//urls.js file

const urls = {
    'allImages': '/images/all/',
    'catImage': '/images/<animal>/<id>/',
};

module.exports = urls;

Use it everywhere you want

import Library from 'js-reverse/js-reverse/reverse-library';
import urls from 'urls';

const library = new Library('big-cat-database.com');
library.register(urls);

Without params in urls

library.get('allImages');
// big-cat-database.com/images/all/

With params in <> brackets

library.get('catImage', {animal: 'cat', id: 9000});
// big-cat-database.com/images/cat/9000/

With query string

library.get('catImage', {animal: 'cat', id: 9000}, {paginateBy: 20, order: 'from_cute_to_ugly'});
// http://big-cat-database.com/images/cat/9000/?paginateBy=20&order=from_cute_to_ugly