Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/simenandre/protobuf-to-runtypes

Generate Runtypes from Protobuf files 🎉
https://github.com/simenandre/protobuf-to-runtypes

converter protobuf protobuf3 runtypes transformer typescript

Last synced: 27 days ago
JSON representation

Generate Runtypes from Protobuf files 🎉

Awesome Lists containing this project

README

        

# Generate Runtypes from Protobuf

[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![NPM version](https://img.shields.io/npm/v/protobuf-to-runtypes.svg)](https://www.npmjs.com/package/protobuf-to-runtypes)
[![codecov](https://codecov.io/gh/cobraz/protobuf-to-runtypes/branch/main/graph/badge.svg)](https://codecov.io/gh/cobraz/protobuf-to-runtypes)

This CLI and library aim to provide an easy way to convert Protobuf to Runtypes.

We are thankful for all help with adding new functionality, fixing issues, or
improve the package. Feel free to open issues and pull requests ❤️

## Quickstart

```shell
▶ npx protobuf-to-runtypes -i protobuf.proto -o protobuf.ts
```

or

```shell
▶ cat https://some-url.com/my-api.proto | npx protobuf-to-runtypes -o protobuf.ts
```

## Documentation

Apart from this README, you can find details and examples of using the SDK in
the following places:

- [API Documentation][docs]

## Example

```typescript
import { parseToGenerator } from 'protobuf-to-runtypes';
import { generateRuntypes } from 'generate-runtypes';

const protobuf = await readFile('my-protobuf.proto');
const toGenerator = await parseToGenerator(protobuf);
const sourceCode = await generateRuntypes(toGenerator);
```

[runtypes]: https://github.com/pelotom/runtypes
[docs]: ./docs