Skip to content

Use protocol buffers to generate a Typescript interface

License

Notifications You must be signed in to change notification settings

ollionorg/protobufjs-typescript-gen

Repository files navigation

@cldcvr/protobufjs-typescript-gen

@cldcvr/protobufjs-typescript-gen is a tool which used protocol buffers to generate a Typescript interface. The tool is currently highly opinionated in how it generates files. It internally uses protobuf.js.

protobuf.js is a pure JavaScript implementation with TypeScript support for node.js and the browser. It's easy to use, blazingly fast and works out of the box with .proto files!

Installation

node.js

$> npm install @cldcvr/protobufjs-typescript-gen [--save --save-prefix=~]
// generate-protocol.js
const { generateProtocol } = require('@cldcvr/protobufjs-typescript-gen');

generateProtocol({
    protocolDir: 'YOUR_PROTOCOL_DIRECTORY',
    outDir: 'YOUR_OUTPUT_DIRECTORY',
});
$> node generate-protocol.js

Example

Please see the examples folder for the structure of the generated interface.

About

Use protocol buffers to generate a Typescript interface

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published