Options
All
  • Public
  • Public/Protected
  • All
Menu

@techrah/cruud-connector - v1.0.12

Index

Type aliases

CRUUDConnectorFn

CRUUDConnectorFn: (req?: CRUUDRequest) => Promise<any>

Type declaration

CRUUDMethod

CRUUDMethod: "create" | "read" | "modify" | "replace" | "delete"

CRUUD Connector

CRUUDMiddleWareFn

CRUUDMiddleWareFn: (connector: CRUUDFns) => Partial<CRUUDFns>

Type declaration

CRUUDMiddlewareApplicator

CRUUDMiddlewareApplicator: (cruudFns: CRUUDFns) => CRUUDConnector

Type declaration

CRUUDRequest

CRUUDRequest: { headers?: {}; httpMethod?: HttpMethod; params?: any[]; query?: {}; url?: string }

Type declaration

  • [key: string]: any
  • Optional headers?: {}
    • [key: string]: string
  • Optional httpMethod?: HttpMethod
  • Optional params?: any[]
  • Optional query?: {}
    • [key: string]: any
  • Optional url?: string

CRUUDResponse

CRUUDResponse: { data: object }

Type declaration

  • data: object

Variables

Const CRUUD_METHODS

CRUUD_METHODS: string[] = ...

Const HTTP_METHODS

HTTP_METHODS: string[] = ...

Functions

applyMiddleware

createConnector

createCruudFns

  • createCruudFns(createConnFn: CRUUDConnectorFnCreator): CRUUDFns
  • A helper function to generate CRUUD functions that are returned from middleware modules or network adapters.

    See middleware and network adapter code for usage.

    Parameters

    • createConnFn: CRUUDConnectorFnCreator

      A factory function that accepts a CRUUD method name and returns a CRUUDConnectorFn.

    Returns CRUUDFns

defaultNetworkAdapter

  • defaultNetworkAdapter(config: FetchConfig): CRUUDFns
  • A network adapter that uses fetch for network requests.

    Parameters

    • config: FetchConfig

      Configuration parameters: baseURL and headers.

      import { createConnector, defaultNetworkAdapter }
      
      const baseURL = "http://api.example.com"
      const networkAdapter = defaultNetworkAdapter({ baseURL })
      const connector = createConnector(networkAdapter)
      connector("/movies/").read()
      

    Returns CRUUDFns

verifyRequest