2.0.5 • Published 9 months ago

@piximind/api v2.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months 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

9 months ago

2.0.2

9 months ago

2.0.5

9 months ago

2.0.4

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.2

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago