Socket
Socket
Sign inDemoInstall

ngx-endpoints

Package Overview
Dependencies
12
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-endpoints

A library to dynamically load data from http endpoints / urls in angular


Version published
Weekly downloads
1
decreased by-93.33%
Maintainers
1
Install size
4.68 MB
Created
Weekly downloads
 

Readme

Source

ngx-endpoints

load data from url-endpoints dynamically at runtime

Demo

https://pharindoko.github.io/ngx-endpoints/sample

Installation

NPM

npm install ngx-endpoints --save

YARN

yarn add ngx-endpoints

Technical Documentation

https://pharindoko.github.io/ngx-endpoints/documentation

Usecase

The assumption is always that you want to GET data.

  • You need to execute url endpoints dynamically in the application.
  • You retrieve urls from a backend and request further data from different urls based on different related objects
  • You want to make date relative requests
  • You want to make live requests and subscribe to it

Dependencies

Makes use of following packages:

  • moment.js
  • moment-relativism
  • query-string

How to integrate into a component

Create an Array of Type NgxEndPoint (Array<NgxEndPointData>)

Attributes

AttributeDescriptionDefault ValueTypeMandatory
titletitle of the url endpoint you request""stringtrue
endPointIdid for later identification (matching)0numbertrue
activeenable or disable endpointtruebooleanfalse
endPointUrlthe url endpoint which will be requested""stringtrue
requestOptionsadd header key/values{}objectfalse
liveDoes the url endpoint deliver live datafalsebooleanfalse
liveintervalIn which timeinterval (milliseconds) the data should be requested3000numberfalse
convertDatesUse relative date expressions in endPointUrl for e.g. for grafana/prometheus - moment-relativismfalsebooleanfalse
convertDatesOutputFormatmoment.js format will be used for conversion before url request will be started-stringfalse

Example

  endPointArray: Array<NgxEndPointData> = [
{
  'title': 'Deutsche Bahn Public Transport API - Jungfernheid',
  'endPointId': 1,
  'active': true,
  'endPointUrl': 'https://2.db.transport.rest/stations?query=jungfernheide',
  'requestOptions': {
    'Content-Type': 'application/json',
  },
  'live': false
},
{
  'title': 'search-meinfernbus-locations - Frankfurt',
  'endPointId': 2,
  'active': true,
  'endPointUrl': 'https://1.flixbus.transport.rest/regions/?query=Frankfurt',
  'requestOptions': {
    'Content-Type': 'application/json',
  },
  'live': true,
  'liveinterval': 10000
}];
1. Import Module
...
import { NgxEndpointsModule} from 'ngx-endpoints';
...


@NgModule({
  declarations: [
  ],
  imports: [
    ...
    NgxEndpointsModule,
  ],
  providers: [],
  bootstrap: []
})
export class AppModule { }

2. Import Classes
import {NgxEndPoint, NgxEndPointDataProviderService, NgxEndPointData, NgxEndpointService} from 'ngx-endpoints';
3. Inject NgxEndpointService and NgxEndPointDataProviderService
constructor(protected endpointservice: NgxEndpointService, protected endpointdataprovider: NgxEndPointDataProviderService) { }
4. Use it in code directly
  • Basic Example
ngOnInit(): void {
  // add to dataprovider service (Endpoints get created)
  for (const dataitem of this.endPointArray) {
    this.endpointdataprovider.addEndPoint(dataitem).requestData();
  }
  // subscribe to specific endpoint
  this.endpointdataprovider.endpoints.find(x => x.endpoint.endPointId === 2).data.subscribe(val => {
    console.log('Value: ' + val);
  });
}

Keywords

FAQs

Last updated on 24 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc