0.0.8 • Published 3 months ago

jattac.lib.apiaccessor v0.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Jattac Computing User API Accessor Helper

This is a wrapper around axios, that allows you to do a one-off, low maintainance configuration for structured REST API calling. It includes methods for making HTTP POST and GET requests to specified endpoints, with optional parameters for customization. Additionally, it incorporates caching to optimize repeated GET requests.

Usage

  1. Installation

    npm i jattac.lib.apiaccessor
  2. Configuration At the entry point of your application configure library as follows

    import { EndpointConfigurationsRegistry, EndpointConfiguration } from 'jattac.lib.apiaccessor';
    
    // Configure at least one endpoint
    
    const endpointConfig = EndpointConfiguration({
      host: 'example.com',
      hostTrailingString: 'api/v1', //optional
      headersResolver: () => {
        const customHeaders = new Map<String, any>();
        customHeaders.set('api-key', 'abcdef');
        return customHeaders;
      }, // optional
      scheme: 'https', // optional, defaults to http
      port: 5113, // optional defaults to 80
    });
    
    EndpointConfigurationsRegistry.registerEndpointConfiguration('my-config', endpointConfig);
  3. Extend ApiAccessorBase

import ApiAccessorBase from 'jattac.lib.apiaccessor';

class MyApiCaller extends ApiAccessorBase{
  controller: string = "users";
  endpointConfigurationName: "my-config"
}

### Properties
- `controller`: Abstract property representing the controller associated with the API.
- `endpointConfigurationName`: Abstract property specifying the name of the endpoint configuration.
0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

5 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.2

12 months ago

0.0.1

12 months ago