trocha

0.2.3 • Public • Published

TrochaJS

TLDR It replace long, ugly, repetitibe url strings with clean objects

MPL license npm version

Commits since release Commits since previous release PRs Welcome

npm downloads Build Status Dependency Status devDependency Status

Test FX Test Chromium Test Edge Test IE Test Node

Contact info Share info

An standalone/agnostic library to print valid URLs, ideal for RESTful & SPA frontEnd big projects.

Why this library exist

This library take inspiration from Ruby routing system, where you describe the routes via a simple name tree and call those routes via dinamic function naming, preventing use of string in views and controllers.

Ugly code example

theRoute =
    'https://my.domain.com.co/product/' +
    myProduct.id +
    '/buy' +
    '?quantity=' +
    sell.quantity

With Trocha

theRoute = myRoutes.product.buy.path({
    product_id: myProduct.id,
    query: { quantity: sell.quantity }
})

This will print

https://my.domain.com.co/product/<product_id>/buy?quantity=<sell.quantity>

Please see the full docs at here: https://dfoxpro.github.io/trochaJS

Package Sidebar

Install

npm i trocha

Weekly Downloads

7

Version

0.2.3

License

MPL-2.0

Unpacked Size

344 kB

Total Files

15

Last publish

Collaborators

  • dfoxpro