Socket
Socket
Sign inDemoInstall

syshub-rest-module

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syshub-rest-module

This package provides a generic library for the communication from an Angular SPA with a NT-Ware uniFLOW sysHUB backend server based on HTTPS Rest API with OAuth2 flow. The contained Rest Service provides methods for login and logout-functionality and an


Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Syshub Rest Module

This package provides a generic library for the communication from an Angular SPA with a NT-Ware uniFLOW sysHUB backend server based on HTTPS Rest API with OAuth2 flow. The contained Rest Service provides methods for login and logout-functionality and an automatic token refresh. Furthermore you can use the get- and post-methods to send a request to any sysHUB Rest API endpoint. The package contains anything needed for the communication, just at it as a provider to your application and provide it with settings like hostname and credentials.

Install

Run npm i syshub-rest-module in your project root to add this library as dependency. After that, create a configuration (for example in your environment.ts) for the credentials:

export const environment = {
    syshub: {
        host: "http://localhost:8088/",
        basic: {
            enabled: false,
            username: "foo",
            password: "foo!bar",
            provider: "<syshubApiserverName>",
        },
        oauth: {
            enabled: true,
            clientId: "<syshubAuthserverClientId>",
            clientSecret: "<syshubAuthserverClientSecret>",
        }
    }
};

Make sure to enable either basic auth or oauth. Basic auth requires an authentication provider that you must set up in API Server configuration. This is not required for OAuth authentication.

Usage

In your app.module.ts add the following three providers:

import { RestService, RestSettings, Settings, SyshubInterceptor } from 'syshub-rest-module';

...

providers: [
    { provide: Settings, multi: false, useValue: new Settings(<RestSettings>(environment.syshub)) },
    { provide: RestService, multi: false, deps: [Settings, HttpClient] },
    { provide: HTTP_INTERCEPTORS, multi: true, useClass: SyshubInterceptor, deps: [Settings, HttpClient] }
  ],

The Settings-provider requires an initialized object of type Settings, where the constructor expects an object that implements the RestSettings interface. For an example, see the Install chapter.

In your components

Within your components you are now able to access all service methods and properties. For example:

import { RestService } from 'syshub-rest-module';

...

export class AppComponent {

    ...

    constructor(private restService: RestService) {}

    ...

    sendLogin(): void {
        this.restService.login(this.username, this.password).subscribe((response) => {
            console.log(response)
            if (response == null) // initial status
                return;
            if (response === true) {
                // login successfull
            }
            else {
                // login failed
            }
        });
    }

    ...

}

Configuration

Comming soon...

Further help

Comming soon...

Keywords

FAQs

Package last updated on 12 Feb 2023

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