Sharing JsonServiceClient.js client with front-end developers

I am developing a solution in concert with another outside developer. The outside developers are using React + JS to build the front-end and I am building the API (with authentication). Unfortunately, they are 2 separate projects, and getting them into a single code base is not an option. If possible, I would like to provide the front-end developers with JsonServiceClient.

Based on the documentation here there seems to be .js version of the client but the links to it our broken. Is there a “distribution” (i.e. file) I can give them?


I’ve updated the links to reference to reference the previously deleted jQuery JsonServiceClient, but any modern JavaScript or TypeScript project should just be using the TypeScript JsonServiceClient, the actual @servicestack/client npm package only contains the generated index.js which can be used in JS or TypeScript like any other module, i.e:

import { JsonServiceClient } from "@servicestack/client";

Which can then be used with the generated DTOs from your API at /types/typescript that they can download either directly and saving to a local file e.g. dtos.ts or use our @servicestack/cli npm tool to download it:

$ npm install -g @servicestack/cli

Then download it with:

$ typescript-ref dtos.ts

They can then use TypeScript on that file to generate the dtos.js version they can use in their JavaScript version:

$ tsc dtos.ts 

Or they can tell TypeScript to generate a different module version that their project uses, e.g:

$ tsc -m ES6 dtos.ts

Which they can then use in their APIs:

import { GetConfig } from './dtos';

var response = await client.get(new GetConfig());

To update when your API changes they can run typescript-ref without any arguments:

$ typescript-ref 

Which will update to the latest version of dtos.ts. This can be easily automated with an npm script, e.g:

  "scripts": {
    "dtos": "cd src/shared && typescript-ref && tsc -m ES6 dtos.ts",

Which will let you update and compile the dtos with:

$ npm run dtos

The TechStacks (Vue/Nuxt) and React Native Mobile App (React) are examples of JavaScript projects which uses the TypeScript Service client in a JavaScript project.

Thank you!!!

Great framework btw.

1 Like