api_interaction_services
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

Api interaction services

All services use fp-ts library, http methods wrapper return fp-ts either.

Simple api interaction class

import { ApiInteractionService } from 'api_interaction_services';

So you can use it like this:

0.2x:

const fetcher = new ApiInteractionService("http://localhost:3300");
fetcher.get('/');

0.3x:

const fetcher = new ApiInteractionService("http://localhost:3300");
fetcher.get('/')();

Indendity interaction service

A more powerful tool that allows you to communicate with a closed API that requires access and refresh tokens.

import { BearerApiInteractionService } from 'api_interaction_services';

Inversify

Or you can use this classes with inverisify in a few steps:

  1. Declare SERVICE_IDENTIFIER name for service
export const SERVICE_IDENTIFIER = {
    ApiInteractionService: Symbol.for("ApiInteractionService"),
};
  1. Bind this name to class with url to your API
container.bind<ApiInteractionService>(SERVICE_IDENTIFIER.ApiInteractionService).toConstantValue(new ApiInteractionService(API_URL));
  1. And now you can inject this service to your class
constructor(@inject(SERVICE_IDENTIFIER.ApiInteractionService) protected _apiService: ApiInteractionService) {}

Readme

Keywords

none

Package Sidebar

Install

npm i api_interaction_services

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

52.3 kB

Total Files

68

Last publish

Collaborators

  • sapfir0