An open API service indexing awesome lists of open source software.

https://github.com/leancodepl/contractsgenerator-typescript


https://github.com/leancodepl/contractsgenerator-typescript

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# LeanCode TypeScript Contracts Generator

## Packages

- [Contracts Generator](packages/generator) - utility for generating contracts/client/schema from backend contracts
- [Admin App Generator](packages/api-admin/) - package for generating strongly typed components from generated schema
and client

## Available plugins

- [contracts](plugins/contracts/) - type generation
- [client](plugins/client/) - api factory generation; requires `contracts` to also be used
- [raw](plugins/raw) - prepend/append text to generated file;
- [admin](plugins/admin) - api components schema generation; used by [Admin App Generator](packages/api-admin/)

## Development

### Local publish

To test your changes to the codebase you can publish all packages to local registry
([Verdaccio](https://verdaccio.org/)) and then pull those packages to your project. To start local registry run

```
npx nx run local-registry
```

this will override your default registry in npm config. To publish all packages to local registry run

```
npx nx run local-publish --ver={VERSION_IN_#.#.#_OR_#.#.#-PREFIX.#} --tag={TAG}
```

### Protobuf

Server and clients communicate using protobuf. Specific `.proto` contract file is being copied from the server
repository to [`libs/schema/src/lib/protocol/contracts.proto`](libs/schema/src/lib/protocol/contracts.proto). This is
important to note that when contracts file is updated on the backend side then updating process is entirely manual.
After you copy new `contracts.proto` file the
[`libs/schema/src/lib/protocol/index.js`](libs/schema/src/lib/protocol/index.js) and
[`libs/schema/src/lib/protocol/index.d.ts`](libs/schema/src/lib/protocol/index.d.ts) need to be updated. Those files are
automatically generated by running `npx nx run schema:proto`.