2.0.5 • Published 2 years ago

@piximind/api v2.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Installation

Using npm

npm i -g npm

npm i @piximind/api

Usage

Method 1: API

const api = new Api()

constructor:

    constructor(apiURL = 'http://localhost', port?: string) 

interface:

interface ApiResponse {
  status: Httpstatus;
  data: any;
}

interface RefreshJson extends Partial<Response> {
  accessToken: string;
  refreshtoken: string;
}

interface IApi {
  get(endPoint: string, headers: Headers, refrechCallback: () => Promise<Response>): Promise<ApiResponse>;
  delete(endPoint: string, body: any, headers: Headers, refrechCallback: () => Promise<Response>): Promise<ApiResponse>;
  post(endPoint: string, body: any, headers: Headers, refrechCallback: () => Promise<Response>): Promise<ApiResponse>;
  put(endPoint: string, body: any, headers: Headers, refrechCallback: () => Promise<Response>): Promise<ApiResponse>;
  patch(endPoint: string, body: any, headers: Headers, refrechCallback: () => Promise<Response>): Promise<ApiResponse>;
}

Method 2: CustomApi

const api = new CustomApi()

constructor:

    constructor(params:ICustomApi) 

interface:

export interface ICustomApi {
  port: number
  apiUrl: string
}

export interface ICallParams {
  endPoint: string
  method: Method
  body?: any
  headers: Headers
  refrechCallback?: () => Promise<Response | string | boolean>
  afterRefreshError?: () => Promise<any>
}

export interface ICustomApi {
  port: number
  apiUrl: string
}

export interface ICustomApiFunction {
  createHeader(headerObject: HeaderObject): Headers;
  call(params: ICallParams): Promise<ApiResponse>;
}
2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago