Skip to content

jin-frame / frames/JinEitherFrame / JinEitherFrame

Class: JinEitherFrame<TPASS, TFAIL>

Defined in: src/frames/JinEitherFrame.ts:31

Definition HTTP Request

Extends

Type Parameters

TPASS

TPASS = unknown

AxiosResponse type argument case of valid status. eg. AxiosResponse<TPASS>

TFAIL

TFAIL = TPASS

AxiosResponse type argument case of invalid status. eg. AxiosResponse<TFAIL>

Implements

Constructors

Constructor

new JinEitherFrame<TPASS, TFAIL>(): JinEitherFrame<TPASS, TFAIL>

Defined in: src/frames/AbstractJinFrame.ts:98

Returns

JinEitherFrame<TPASS, TFAIL>

Inherited from

AbstractJinFrame.constructor

Properties

$_data

protected $_data: IFrameInternal

Defined in: src/frames/AbstractJinFrame.ts:96

Inherited from

AbstractJinFrame.$_data


$_option

protected $_option: IFrameOption

Defined in: src/frames/AbstractJinFrame.ts:94

Inherited from

AbstractJinFrame.$_option

Methods

$_postHook()

protected $_postHook(_req, _reply): void | Promise<void>

Defined in: src/frames/JinEitherFrame.ts:52

Execute after request.

Parameters

_req

TJinRequestConfig

_reply

IFailReplyJinEitherFrame<TFAIL> | TPassJinEitherFrame<TPASS>

Returns

void | Promise<void>


$_preHook()

protected $_preHook(_req): void | Promise<void>

Defined in: src/frames/JinEitherFrame.ts:42

Execute before request. If you can change request object that is affected request.

Parameters

_req

TJinRequestConfig

Returns

void | Promise<void>


$_retryFail()

protected $_retryFail(_req, _res): void

Defined in: src/frames/AbstractJinFrame.ts:92

Parameters

_req

AxiosRequestConfig

_res

AxiosResponse<TPASS>

Returns

void

Inherited from

AbstractJinFrame.$_retryFail


create()

create(option?): () => Promise<PassFailEither<IFailReplyJinEitherFrame<TFAIL> | IFailCreateJinEitherFrame<TFAIL>, TPassJinEitherFrame<TPASS>>>

Defined in: src/frames/JinEitherFrame.ts:90

Generate an AxiosRequestConfig value and use it to return a functions that invoke HTTP APIs

Parameters

option?

IJinFrameRequestConfig & IJinFrameCreateConfig

same with AxiosRequestConfig, bug exclude some filed ignored

Returns

Functions that invoke HTTP APIs

(): Promise<PassFailEither<IFailReplyJinEitherFrame<TFAIL> | IFailCreateJinEitherFrame<TFAIL>, TPassJinEitherFrame<TPASS>>>

Returns

Promise<PassFailEither<IFailReplyJinEitherFrame<TFAIL> | IFailCreateJinEitherFrame<TFAIL>, TPassJinEitherFrame<TPASS>>>

Implementation of

IJinFrameFunction.create


execute()

execute(option?): Promise<PassFailEither<IFailReplyJinEitherFrame<TFAIL> | IFailCreateJinEitherFrame<TFAIL>, TPassJinEitherFrame<TPASS>>>

Defined in: src/frames/JinEitherFrame.ts:184

Generate an AxiosRequestConfig value and invoke HTTP APIs

Parameters

option?

IJinFrameRequestConfig & IJinFrameCreateConfig

same with AxiosRequestConfig, bug exclude some filed ignored

Returns

Promise<PassFailEither<IFailReplyJinEitherFrame<TFAIL> | IFailCreateJinEitherFrame<TFAIL>, TPassJinEitherFrame<TPASS>>>

AxiosResponse With PassFailEither

Implementation of

IJinFrameFunction.execute


executePostHook()

executePostHook(req, reply): Promise<CE_HOOK_APPLY>

Defined in: src/frames/JinEitherFrame.ts:203

Parameters

req

AxiosRequestConfig<unknown>

reply

IFailReplyJinEitherFrame<TFAIL> | TPassJinEitherFrame<TPASS>

Returns

Promise<CE_HOOK_APPLY>


executePreHook()

executePreHook(req): Promise<CE_HOOK_APPLY>

Defined in: src/frames/JinEitherFrame.ts:193

Parameters

req

AxiosRequestConfig<unknown>

Returns

Promise<CE_HOOK_APPLY>


getData()

getData<K>(kind): Pick<IFrameInternal, "body" | "header" | "param" | "query" | "retry" | "instance">[K]

Defined in: src/frames/AbstractJinFrame.ts:105

Type Parameters

K

K extends "body" | "header" | "param" | "query" | "retry" | "instance"

Parameters

kind

K

Returns

Pick<IFrameInternal, "body" | "header" | "param" | "query" | "retry" | "instance">[K]

Inherited from

AbstractJinFrame.getData


getFormData()

getFormData(bodies): unknown

Defined in: src/frames/AbstractJinFrame.ts:140

Parameters

bodies

unknown

Returns

unknown

Inherited from

AbstractJinFrame.getFormData


getOption()

getOption<K>(kind): IFrameOption[K]

Defined in: src/frames/AbstractJinFrame.ts:111

Type Parameters

K

K extends keyof IFrameOption

Parameters

kind

K

Returns

IFrameOption[K]

Inherited from

AbstractJinFrame.getOption


getTransformRequest()

getTransformRequest(): undefined | AxiosRequestTransformer | AxiosRequestTransformer[]

Defined in: src/frames/AbstractJinFrame.ts:121

Returns

undefined | AxiosRequestTransformer | AxiosRequestTransformer[]

Inherited from

AbstractJinFrame.getTransformRequest


request()

request(option?): AxiosRequestConfig

Defined in: src/frames/AbstractJinFrame.ts:182

AxiosRequestConfig create using by class member variable.

Parameters

option?

IJinFrameRequestConfig & IJinFrameCreateConfig

same with AxiosRequestConfig, bug exclude some filed ignored

Returns

AxiosRequestConfig

created AxiosRequestConfig

Inherited from

AbstractJinFrame.request


requestWrap()

requestWrap(option?): PassFailEither<JinCreateError<JinEitherFrame<TPASS, TFAIL>, TPASS, TFAIL>, AxiosRequestConfig<unknown>>

Defined in: src/frames/JinEitherFrame.ts:57

Parameters

option?

IJinFrameRequestConfig & IJinFrameCreateConfig

Returns

PassFailEither<JinCreateError<JinEitherFrame<TPASS, TFAIL>, TPASS, TFAIL>, AxiosRequestConfig<unknown>>


retry()

retry(req, isValidateStatus): Promise<AxiosResponse<TPASS, any>>

Defined in: src/frames/AbstractJinFrame.ts:290

Parameters

req

AxiosRequestConfig

isValidateStatus

(status) => boolean

Returns

Promise<AxiosResponse<TPASS, any>>

Inherited from

AbstractJinFrame.retry


setFields()

setFields(args): void

Defined in: src/frames/AbstractJinFrame.ts:115

Parameters

args

JinEitherFrame<TPASS, TFAIL>

Returns

void

Inherited from

AbstractJinFrame.setFields


builder()

static builder<T, C>(this): TBuilderFor<T, C>

Defined in: src/frames/AbstractJinFrame.ts:45

Type Parameters

T

T

C

C extends TConstructorFunction<T>

Parameters

this

C

Returns

TBuilderFor<T, C>

Inherited from

AbstractJinFrame.builder


getDefaultValues()

protected static getDefaultValues(): Partial<TFieldsOf<InstanceType<typeof this>>>

Defined in: src/frames/AbstractJinFrame.ts:40

Returns

Partial<TFieldsOf<InstanceType<typeof this>>>

Inherited from

AbstractJinFrame.getDefaultValues


getEndpoint()

static getEndpoint(): URL

Defined in: src/frames/AbstractJinFrame.ts:34

Returns

URL

Inherited from

AbstractJinFrame.getEndpoint


of()

static of<T, C>(this, args): InstanceType<C>

Defined in: src/frames/AbstractJinFrame.ts:71

Type Parameters

T

T

C

C extends TConstructorFunction<T>

Parameters

this

C

args

Readonly<NonFunctionProps<InstanceType<C>>> | (b) => unknown

Returns

InstanceType<C>

Inherited from

AbstractJinFrame.of