GitXplorerGitXplorer
l

js-reverse

public
0 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
94320898c3861d8c96e9ce6a40b7b9a02e8ca36c

Usage comment added

committed 6 years ago
Unverified
b315e79188689a26fb929676436fe248d2584c76

js-reverse/reverse-namespace.js

committed 6 years ago
Unverified
821ae7c88b2588138d4b2e564040cde395606b8c

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

committed 6 years ago
Unverified
4a11917c7ab9cec41062183e3c873c7e8b63f96c

Deleted getQuerystring method call

committed 6 years ago
Verified
016eb34af13b947b3096f909ad0bb4e0b506923e

Update README.md

committed 6 years ago
Unverified
8dcaf2a92d5706bb3ab49bf72f927e19bc7d8acf

Added eslintrc to .gitignore

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