Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-http-sw-proxy

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-http-sw-proxy

Proxy for angular http service. Schedules request send in service-worker and/or IndexedDB.

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75
increased by3650%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Build Status

ng-http-sw-proxy

This service proxies Angular http traffic via service worker. It is collecting sent http requests in IndexedDB and providing them to service-worker 'sync' job.

Workflow

ng-http-sw-proxy flowchart

Installation

npm install --save ng-http-sw-proxy
cp -r node_modules/ng-http-sw-proxy/service-worker ./src

Compilation

When compilation of your project is done, you need to combine service worker script. Rollup will automatically move it to your dist folder.

node src/service-worker/rollup.js

Usage

in your main module:

import { HttpSwProxyModule } from 'ng-http-sw-proxy';

@NgModule({
  imports: [
    HttpSwProxyModule,
    /* other modules*/
  ],
})
export class AppModule {
}

After importing HttpSwProxyModule @angular http service is shadowed with the new one, from ng-http-sw-proxy. component/services looks like previous:

import { Http } from '@angular/http';

@Component({
/* component setup*/
})
export class HttpProxyDemoComponent {

    public response: Observable<any>;

    constructor(private http: Http) {}

    public sendPost():void {
        this.response = this.http.post("testPost", {exampleKey: "exampleValue"}).map(res => res.json());
    }
}

Finally initialize service worker in your main file:

platformBrowserDynamic().bootstrapModule(BrowserAppModule).then(() => {
    if (process.env.NODE_ENV == 'production' && 'serviceWorker' in navigator)
        navigator.serviceWorker.register('./worker-basic.min.js').then(() => navigator.serviceWorker.ready);
});

Examples

Something missing? More documentation? Bug fixes? All PRs welcome at https://github.com/maciejtreder/ng-http-sw-proxy

Keywords

FAQs

Package last updated on 13 Jul 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc