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

exc-rest-v2

v1.0.12

Published

##### Content - ExcRestModule

Downloads

19

Readme

Module Exc-Rest-V2

Content
  • ExcRestModule
Services
  • ExcRestService
  • ExcTranslateService
Enumerations
  • ExcRestMode
Interfaces
  • IExcDataFilter
  • IExcDataPaging
  • IExcDataSort
  • IExcMetaInfo
  • IExcRestConfig
  • IExcRestRequestConfig
  • IRequestOptions
Pipes
  • ExcDatePipe
  • ExcCurrencyPipe

Dependencies

  • exc-core-v2

Install

To install ExcRestModule into your project use

npm i exc-rest-v2

ExcRestService

Dependencies

  • Register environment into ExcCoreModule.Config() with ExcCoreModule.RegisterConfig('Environment',environment)
  • Prepare environment.ts for the endpoints
export const environment = {
  production: false,
  sec: {},
  rest: {
    ServiceUrl: 'Base URL of Service with trailing /',
    LoginUrl: 'Base URL of Security Service with trailing /',
    Endpoints: {
      PasswordSettings: 'PasswordSettings'
    }
  }
};

Setup

To use ExcRestService you have to do preparations in your project.

  1. app.module.ts
//...
import {environment} from '../environments/environment';
import {ExcCoreModule} from 'exc-core-v2';
import {ExcRestModule, ExcRestService, ExcRestMode} from 'exc-rest-v2';
import {AppComponent} from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ExcCoreModule,
    ExcRestModule
    //...
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(private excRest: ExcRestService) {
    ExcCoreModule.RegisterConfig('Environment', environment);
    excRest.Mode = ExcRestMode.GROOT; /* GROOT is default-mode this line could be removed */
  }
}
  1. app.component.ts
//...
import {ExcCoreModule} from 'exc-core-v2';
import {ExcRestService} from 'exc-rest-v2';

//...
export class AppComponent implements OnInit {
//...
  constructor(private excRestService: ExcRestService) {
  }
}

Definitions

Properties

| Name | Type | Description | | --- | --- | --- | | Mode | ExcRestMode | Get or set the mode of ExcRestService.(Default: ExcRestMode.GROOT) |

Methods

get(url, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}

excRest.get(url).subscribe((response: any) => {
})
excRest.get(url, config).subscribe((response: any) => {
})
excRest.get(url, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
sget(url, id, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | id | string | ID of the request to identify the correct last response of multiple calls | | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const callID = '08154711'
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}

excRest.sget(url, callID).subscribe((response: any) => {
})
excRest.sget(url, callID, config).subscribe((response: any) => {
})
excRest.sget(url, callID, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
put(url, data, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | data | any | Payload of the request | | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}
const data: { Name: 'Doe', Firstname: 'John' }

excRest.put(url, data).subscribe((response: any) => {
})
excRest.put(url, data, config).subscribe((response: any) => {
})
excRest.put(url, data, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
sput(url, data, id, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | data | any | Payload of the request | | id | string | ID of the request to identify the correct last response of multiple calls | | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const callID = '08154711'
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}
const data: { Name: 'Doe', Firstname: 'John' }

excRest.sput(url, data, id).subscribe((response: any) => {
})
excRest.sput(url, data, id, config).subscribe((response: any) => {
})
excRest.sput(url, data, id, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
post(url, data, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | data | any | Payload of the request | | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}
const data: { Name: 'Doe', Firstname: 'John' }

excRest.post(url, data).subscribe((response: any) => {
})
excRest.post(url, data, config).subscribe((response: any) => {
})
excRest.post(url, data, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
delete(url, data?, config?, mode?)
Parameters

| Name | Type | Description | | --- | --- | --- | | url | string | URL for the request| | data? | any | (optional) Payload of the request | | config? | IExcRestRequestConfig undefined | (optional) configuration for the request.| | mode? | ExcRestMode undefined | (optional) mode for the call, if different from default mode in ExcRestService |

Returns

Observable<any>

Examples
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test';
const config: ExcRestRequestConfig = {}
const data: { ID: 11, Name: 'Doe', Firstname: 'John' }

excRest.delete(url).subscribe((response: any) => {
})
excRest.delete(url, data).subscribe((response: any) => {
})
excRest.delete(url, data, config).subscribe((response: any) => {
})
excRest.delete(url, data, config, ExcRestMode.BASIC).subscribe((response: any) => {
})
computeUrl(name, pObj?)
Parameters

| Name | Type | Description | | --- | --- | --- | | name | string | Full-URL or Name of the endpoint in the rest config in environment.ts| | pObj? | any | (optional) Object with placeholder replacement for the url |

Returns

string

Examples
const excRest = ExcCoreModule.Services().ExcRest;
const url = 'https://localhost/test/{ID}';
const data: { ID: 11, Name: 'Doe', Firstname: 'John' }

excRest.computeUrl(url); // returns https://localhost/test/{ID}
excRest.computeUrl(url, data); // returns https://localhost/test/11?Name=Doe&Firstname=John

ExcTranslateService

Dependencies

  • ExcRestService
  • Created asset files (ALPHA-2) for each supported language ####Example
assets/i18n/GROOT/de.json
assets/i18n/de.json

Setup

Extend the following files

  1. app.module.ts Please be sure, that you inject ExcTranslateService after ExcRestService, because it depends on it.
//...
import {environment} from '../environments/environment';
import {ExcCoreModule} from 'exc-core-v2';
import {ExcRestModule, ExcRestService, ExcRestMode, ExcTranslateService} from 'exc-rest-v2';
import {AppComponent} from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ExcCoreModule,
    ExcRestModule
    //...
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(private excRest: ExcRestService, private excTranslate: ExcTranslateService) {
    ExcCoreModule.RegisterConfig('Environment', environment);
    excRest.Mode = ExcRestMode.GROOT; /* GROOT is default-mode this line could be removed */
    excTranslate.activate(); /* Activation of ExcTranslateService */
  }
}
  1. app.component.ts
//...
import {ExcCoreModule, ExcTranslation} from 'exc-core-v2';
import {ExcRestService} from 'exc-rest-v2';

//...
export class AppComponent extends ExcTranslation implements OnInit {
//...
  constructor(private excRestService: ExcRestService) {
    super();
  }
}

Now you are able to use ExcTranslationService. It is automatically available in ExcTranslation class.

  1. Implementing Subscriber for language change
 export class AppComponent extends ExcTranslation implements OnInit {
//...
  constructor(private excRestService: ExcRestService) {
    super();
    this.onLangChange.subscribe(() => {
      // Do anything;
    });
  }
}
  1. Implementing language change
export class AppComponent extends ExcTranslation implements OnInit {
//...
  setLanguage(lang: string): void {
    ExcCoreModule.Services().TranslateService.setLanguage(lang).subscribe();
  }
}