https://github.com/leancodepl/contractsgenerator-typescript
https://github.com/leancodepl/contractsgenerator-typescript
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/leancodepl/contractsgenerator-typescript
- Owner: leancodepl
- License: apache-2.0
- Created: 2021-12-01T09:59:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-19T16:40:36.000Z (over 1 year ago)
- Last Synced: 2025-03-23T18:53:10.594Z (about 1 year ago)
- Language: JavaScript
- Size: 1.5 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
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`.