🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

retrojs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retrojs

RetroJS is a simple HTTP Client for JavaScript that heavily uses ES2016 decorators. Inspired by [Retrofit](http://square.github.io/retrofit/)

Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
7
-36.36%
Maintainers
1
Weekly downloads
 
Created
Source

RetroJS

RetroJS is a simple HTTP Client for JavaScript that heavily uses ES2016 decorators. Inspired by Retrofit

Example

import * as request from 'request';
import * as RetroJS from 'retrojs';

const {RetroBuilder, RetroClient} = RetroJS;
const {GET, POST, DELETE, PUT, Body, Path, Query} = RetroJS.decorators;

class GithubService {
    @GET('users/{user}/repos?sort=pushed')
    listRepos( @Path('user') user: string, @Query('type') type: string): RetroJS.ICall<any[]> {
        return null;
    }
}

// Optional: Use a custom client
const client: RetroJS.IHttpClient = new RetroClient(request.defaults({
    headers: {
        'User-Agent': 'request'
    }
}));

const retro = new RetroBuilder()
    .client(client)
    .baseUrl('https://api.github.com/')
    .build();

// Use the Retro instance to instantiate the class
const githubService = retro.create(GithubService);

const call = githubService.listRepos('benjaminRomano', 'owner');

call.execute().then(result => {
    console.log(result.body.length);
});

Decorators

/* Method Decorators */
@POST('path')
@GET('path')
@DELETE('path')
@PUT('path')

/* Parameter Decorators */
someFunction(@Body body: any);
someFunction(@Query('type') type: string);
someFunction(@Path('user') user: string);

FAQs

Package last updated on 28 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts