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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-api-gun

v1.5.0

Published

The AngularJS Http Client Wrapper Created to Ease things up. Buffer each and evry requests and track the response.

Downloads

4

Readme

NgxApiGun

The AngularJS Http Client Wrapper Created to Ease things up. Buffer each and evry requests and track the response.

You can use this advantage and shoot multiple requests to the server and

  1. later on check the response
  2. Get all the request where Error occoured
  3. Check if any pending Offline request (request made while client was offline)
  4. Retry Errors
  5. Retry Offlines

#OR

You can just simply let the library do make the request and then let just track if any errors.

clearAll(), or specific buffer when you feel its the right time.!!!!

Installation

To install this library, run:

$ npm install ngx-api-gun --save

Consuming this library

You can import your library in any Angular application by running:

$ npm install ngx-api-gun

and then from your Angular AppModule:

File : app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { AppComponent } from './app.component';

import { ApiGunModule, ApiGunService, BufferType, RequestBullet, RequestType } from 'ngx-api-gun'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    HttpClientModule,
    BrowserModule,
    FormsModule,
    //our module
    ApiGunModule
  ],
  //our service Note: In later updated forRoot() added.
  providers: [ApiGunService],
  bootstrap: [AppComponent]
})
export class AppModule { }

and then from your Angular AppModule:

File : app.component.ts

import { Component } from '@angular/core';

// New import
import { ApiGunModule, ApiGunService, BufferType, RequestBullet, RequestType } from 'ngx-api-gun'

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  // Initilizing Bullets
  Req: RequestBullet = new RequestBullet();
  // Injection of Gun Service
  constructor(public _gun: ApiGunService) {

  }

  addHeader() {
    this._gun.appendHeader('key', 'value');
  }
  
  addAuthorization() {
    this._gun.setBasicAuthorizationHeader('username','password');
  }


  addRequest() {
    // Object.assign
    let x = JSON.parse(JSON.stringify(this.Req));
    //load a single request to buffer it 
    let id = this._gun.loadSingleBullet(x);
    //initialize again
    this.Req = new RequestBullet();
  }

  shootRequest() {
      // shoot all pending request
    this._gun.fire();
  }

  logSuccess() {
    this._gun.logBufferToConsole(BufferType.SUCCESS);
  }
  logError() {
    this._gun.logBufferToConsole(BufferType.ERROR);
  }
  logAll() {
    this._gun.logBufferToConsole(BufferType.MAIN);
  }
  // simply retry errors any time.
  retryError() {
    this._gun.retryErrors();
  }
  retryOffline() {
    this._gun.retryOfflines();
  }
  setBufferToLocal() {
    this._gun.saveBulletsToLS();
  }

  setBufferFromLocal() {
    this._gun.loadBulletsFromLS();
  }

}

View

File : app.component.html

<div>
<ul>
  <li>
    <input [(ngModel)]="Req.url" />
  </li>
  <li>
    <input [(ngModel)]="Req.data" />
  </li>
  <li>
    <button (click)="addRequest()">Add</button>
  </li>
  <li>
    <button (click)="shootRequest()">Shoot</button>
  </li>
  <li>
    <button (click)="logError()">Log Error</button>
  </li>
  <li>
    <button (click)="logAll()">Log Pending</button>
  </li>
  <li>
    <button (click)="logSuccess()">Log Success</button>
  </li>
  <li>
    <button (click)="retryError()">Retry Error</button>
  </li>
  <li>
      <button (click)="setBufferToLocal()">Save Locally</button>
   </li>
   <li>
      <button (click)="setBufferFromLocal()">get from LS</button>
   </li>
</ul>
</div>

Once your library is imported, you can use its components, directives and pipes in your Angular application:

Component API

Get a complete detail here

Issues

Please report bugs and issues here.

Docs

Get a complete detail here

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run packagr

To lint all *.ts files:

$ npm run lint

To docs

$ npm run docs:build

Change log

v1.5.0

  • ecrypting before saving to LS and Buffer change to BufferType

v1.4.0

  • Remove abstracted component.

v1.3.0

  • Working Library , with all abstraction

License

MIT © Sourabh Rustagi