open-index/open-npm huggingface dataset:
npm package: @hmxlabs/dax-client
Description: DAX Client library for calling the DAX Server API
Latest version: 3.3.0

# 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, ListingDetail } from "dax-client";

const getListings = (listingType: string, listingStatus: string): Promise<ListingDetail[]> => {
    return daxApi.listingDetailFindAllByTenantId<ListingDetail[]>(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, ListingDetail } from "dax-client";`