Legitcode/legible

Name: legible

Owner: Legitcode

Description: the cleanest way to make http requests in js / node

Created: 2016-12-06 01:24:18.0

Updated: 2017-12-12 21:00:52.0

Pushed: 2017-05-25 20:31:06.0

Homepage: null

Size: 34

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

CircleCI
All Contributors

Legible

See my blog post on why I made this

Proof of concept at making http requests easier to work with in JS / Node. This wraps the fetch api.

install legible --save

A request library using template literals. Making requests has never been so straight forward! Make it easy for users to adopt your api, document it using this library, and everyone will understand making requests.

Example
rt request from 'legible'

c function TestRequest() {
t body = {
email: 'test@test.com',
password: 'secret'


t response = await request`
url: https://api.myapp.com/register
method: POST
body: ${body}
headers: ${{
  Authorization: 'Bearer: token'
}}


Partial Requests

New in 0.2.0!

Using template strings, we can pull out variables easily and keep requests as legible as possible. Imagine splitting out your code like this using api libraries that include requests like so:

rt { partial } from 'legible'

t twitter = {
gister: partial`
url: https://api.twitter.com/register,
method: POST



ter.register`
dy: ${{
email: 'test@test.com',
password: 'Tester'


Middleware

Coming Soon The following isn't implemented yet.

rt request from 'legible'

est.middleware({
aders: {
Authorization: `Bearer: ${localStorage.getItem('token')}`

ter({ headers }) {
localStorage.setItem('token', headers.Authorization)


Contributors

Thanks goes to these wonderful people (emoji key):

|
Zach Silveira

? ? ? |
Ray Gesualdo

? ? | | :—: | :—: |

This project follows the all-contributors specification. Contributions of any kind welcome!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.