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

ng-apiutils-client

v0.0.1

Published

ng-apiutils-client provides everyday functionality for web application development.

Downloads

3

Readme

ng-apiutils-client

ng-apiutils-client is a library for Angular that provides encryption and decryption functionality for HTTP requests and responses. It allows you to encrypt outgoing request data and decrypt incoming response data, providing an additional layer of security for communications between the client and the server.

How to install it

To install the library, simply run the following command in your Angular project:

npm install --save ng-apiutils-client

Use

Setting

First, you need to configure the library in your Angular application. For this you must import the interceptors that will be in charge of capturing the requests sent and the responses received.

import { EncryptionInterceptor, DecryptionInterceptor } from 'apiutils-client';

Add the corresponding providers:

  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: EncryptionInterceptor,
      multi: true
    },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: DecryptionInterceptor,
      multi: true
    },
    { provide: 'apiKey', useValue: 'TU_API_KEY' } // Reemplaza 'TU_API_KEY' con tu API key
  ]

You will obtain the value of the provide apiKey in your Rest API by installing the apiutils.js library and executing the npx generate-key command.

This is an example of what your app.module.ts would look like

import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { EncryptionInterceptor, DecryptionInterceptor } from 'apiutils-client';

@NgModule({
  declarations: [

  ],
  imports: [
    BrowserModule,
    HttpClientModule
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: EncryptionInterceptor,
      multi: true
    },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: DecryptionInterceptor,
      multi: true
    },
    { provide: 'apiKey', useValue: 'TU_API_KEY' } // Replace 'YOUR_API_KEY' with your API key
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Encryption and Decryption

Once the library is configured, your HTTP requests will automatically be encrypted and decrypted by the library.

import { Component } from '@angular/core';
import { ApiService } from './api.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  constructor(private apiService: ApiService) {}

  sendData() {
    const data = { message: 'Hello, server!' };
    this.apiService.postData(data).subscribe(response => {
      console.log('Response from server:', response); 
      /**
      {
    * "signature": "b63043c89b59b77efb3ad0770413d533a4a1737cacbbdce7afd636072d475f84",
    * "data": "U2FsdGVkX1/dcCezAEYM6AEpzQLo0RW2a67PrQm733MV5DdCH59l7HrV1xK2H4RAgDuFB84H8ZQLdIH6ngWMAhTeeyPkM8kFv* +X36fIPPiO56jhZZPYozUUzPaCsC2ySbcJy046UREeVt+pNqqwLzEIxUBmBPQP2SSXQLOnM/DfVya2NfxmDPpmPfQ4tuksw"
    }*/
    });
  }

}

Handle Errors

The library automatically handles errors that may occur during the encryption and decryption process. If there are any errors, an HttpErrorResponse will be raised which can be caught and handled in your code.

License

This project is licensed under the MIT License.