Shared API client

The only shared package is defined inside packages/api-client.

api-client contains the shared API definition for both client and server:

  • The server uses it to implement the API
  • The client uses it to generate a type-safe client

This shared package only needs a package.json and a tsconfig.json file. The key configuration here is adding exports inside package.json to mark the entry points.

This is how the final package.json looks like:

package.json
{
  "name": "@app/api-client",
  "version": "0.0.0",
  "author": "Typeonce",
  "license": "MIT",
  "exports": {
    ".": "./src/api.ts",
    "./schemas": "./src/schemas/paddle.ts"
  },
  "scripts": {
    "typecheck": "tsc"
  },
  /// ...dependencies
}

All the code is implemented inside the src folder.