npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rx-restful-client

v0.2.0

Published

Project that make RESTful API's easier to declare and use within your application. Needs the RxJS to work properly.

Readme

rx-restful-client

Define the Api Http Client Adapter Class (axios-http-client.ts)

AxiosHttpClient

import {from, Observable} from "rxjs";

export class AxiosHttpClient implements GenericHttpClientAdapter<AxiosRequestConfig, AxiosResponse> {

    private readonly axios: Axios;

    constructor() {
        this.axios = new Axios();
    }

    delete<T>(path: string, options?: AxiosRequestConfig): Observable<AxiosResponse<T>> {
        return from(this.axios.delete<T>(path, options));
    }

    get<T>(path: string, options?: AxiosRequestConfig): Observable<AxiosResponse<T>> {
        return from(this.axios.get<T>(path, options));
    }

    patch<T>(path: string, body: any, options?: AxiosRequestConfig): Observable<AxiosResponse<T>> {
        return from(this.axios.patch<T>(path, options));
    }

    post<T>(path: string, body: any, options?: AxiosRequestConfig): Observable<AxiosResponse<T>> {
        return from(this.axios.post<T>(path, body, options));
    }

    put<T>(path: string, body: any, options?: AxiosRequestConfig): Observable<AxiosResponse<T>> {
        return from(this.axios.put<T>(path, body, options));
    }

}

Define the Basic Api Class (axios-api.ts)

AxiosApi

export class AxiosApi extends GenericRestApi<AxiosRequestConfig, AxiosResponse, AxiosHttpClient> {

    readonly condos = new CondosResource(this);
    readonly parkings = new ParkingsResource(this);
    readonly apartments = new ApartmentsResource(this);

    constructor() {
        super(new AxiosHttpClient(), 'https://axios-api.com');
    }
}

Define the Basic Class Types (axios-types.ts)

export class AxiosResource extends GenericRestResource<AxiosRequestConfig, AxiosResponse, AxiosApi> {
    constructor(api: AxiosApi, path: string) {
        super(api, path);
    }
}
export class AxiosRestfulCollection
    extends GenericRestfulCollection<AxiosRequestConfig, AxiosResponse, AxiosApi> {
    constructor(api: AxiosApi, path: string) {
        super(api, path);
    }
}
export class AxiosRestfulResource<T extends AxiosRestfulCollection>
    extends GenericRestfulResource<AxiosRequestConfig, AxiosResponse, AxiosApi, T> {
    constructor(api: AxiosApi, path: string, supplier: (path: string) => T) {
        super(api, path, supplier);
    }
}

Define the RestResource Classes

CondosResource, CondosCollection

export class CondosResource extends AxiosRestfulResource<CondosCollection> {

    constructor(api: AxiosApi, path: string = '') {
        super(api, `${path}/condos`, path => new CondosCollection(api, path));
    }
}

class CondosCollection extends AxiosRestfulCollection {

    readonly parkings = new ParkingsResource(this.api, this.path);
    readonly apartments = new ApartmentsResource(this.api, this.path);

    constructor(api: AxiosApi, path: string) {
        super(api, path);
    }
}

ParkingsResource

export class ParkingsResource extends AxiosResource {
    constructor(api: AxiosApi, path: string = '') {
        super(api, `${path}/parkings-areas`);
    }

    availables(): Observable<AxiosResponse<number[]>> {
        return this.doGet('/available');
    }
}

ApartmentsResource, ApartmentsCollections

export class ApartmentsResource extends AxiosRestfulResource<ApartmentsCollection> {

    constructor(api: AxiosApi, path: string = '') {
        super(api, `${path}/apartments`, path => new ApartmentsCollection(api, path));
    }
}

class ApartmentsCollection extends AxiosRestfulCollection {

    constructor(api: AxiosApi, path: string) {
        super(api, path);
    }
    
    reserve(): Observable<AxiosResponse> {
        return this.doPut<any>('/reserve', {});
    }
    
    cancelReserve(): Observable<AxiosResponse> {
        return this.doGet<any>('/cancel-reserve');
    }
}

Call the API path you want from your application

const api = new AxiosApi();
api.condos.id(1).apartments.id(2).reserve().subscribe((next: any) => {
        console.log('api.condos.id(1).apartments.id(2).reserve()', next);
    },
);

The above example will generate an HTTP call with the path bellow:

https://axios-api.com/condos/1/apartments/2/reserve