2.8.0 • Published 2 hours ago

@hmxlabs/dax-client v2.8.0

Weekly downloads
-
License
-
Repository
github
Last release
2 hours ago

DAX Client

Client API used to call the DAX Server from a React web application. To work correctly you need to have the following in place:

  • Your tentant ID must be specified in the following environment variable: REACT_APP_TENANT_ID
  • A reverse proxy which detects calls to '/dax-api' and redirects the calls the correct DAX server. It should also remove '/dax-api' from the url.

Most of the client code is automatically generated from the DAX Server API swagger page by running the following script:

npm run generate-dax-api

The files are output to '/src/services/generated/'.

dax-api-service.ts is a wrapper around the generated code to automatically specify the tenant Id and improve the request/response data types of the various calls.

Note: This is a work in progress so only some of the routes have wrappers in dax-api-service.ts

For routes which don't have a wrapper method implemented yet, you can call the route directly via the daxApi. For example:

import { daxApi, ListingDetailFindAllResponse } from "dax-client";

const getListings = (listingType: string, listingStatus: string): Promise<ListingDetailFindAllResponse[]> => {
    return daxApi.listingDetailFindAllByTenantId<ListingDetailFindAllResponse[]>(myTenantId, {listingType, listingStatus});
}

Available Scripts

In the project directory, you can run:

npm run build

Generate the npm package to the build folder.

npm run generate-dax-api

Regenerate the client api code from the dax server api swagger page. It requires the dax server api to be running locally to work.

Using the DAX Client

If you check out this repo then you can use the client directly. Assuming your directory structure is something like:

  • dax-client
  • react-web-app

In dax-client, run:

npm run build

In react-web-app, run:

npm i --save ../dax-client

Then you can access the wrapper methods and models from dax-client. For example:

import { listingDetailById, listingDetailFindAll, ListingDetailFindAllResponse, ListingDetailGetByIdResponse } from "dax-client";

2.7.0

2 hours ago

2.8.0

2 hours ago

2.6.0

1 month ago

2.5.0

2 months ago

2.4.0

2 months ago

2.3.0

2 months ago

2.2.0

3 months ago

2.1.0

3 months ago

2.0.0

3 months ago

1.0.10

4 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

6 months ago

1.0.6

6 months ago