Skip to content

A variety of command-line tools are provided to help developers build a base microservice.

License

Notifications You must be signed in to change notification settings

niklaus0823/matrixes-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matrixes

Tools for developing with Microservice on Node.js.

Prerequisites

npm install protoc-gen-grpc -g

Install

npm install matrixes-cli -g

matrix --help
matrix proto --help
matrix grpc --help

Support

  • Automatically generate validation code for GET / POST / gRPC params.
  • Automatically generate mock data as the response of the gateway api.
  • Automatically generate unit test code for micro services

Command

Command: Proto

Generate:

  • NodeJs source codes
  • Typescript d.ts definitions of previous js codes
  • Swagger json

from proto files.

matrix proto [options]

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -p, --proto <dir>      directory of source proto files
    -o, --output <dir>     directory to output codes
    -i, --import <items>   third party proto import path: e.g path1,path2,path3
    -e, --exclude <items>  files or paths in -p shall be excluded: e.g file1,path1,path2,file2
    -j, --javascript       add -j to output javascript codes
    -t, --typescript       add -t to output typescript d.ts definitions
    -s, --swagger          add -s to output swagger json
    -a, --all              also parse & output all proto files in import path?

Command: grpc

Generate:

  • Nodejs source code for creating the GRPC client
  • Nodejs source code for creating the GRPC server api
  • Nodejs source code for creating the KOA gateway api

from proto files.

matrix grpc [options]

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    -p, --proto <dir>       directory of proto files
    -o, --output <dir>      directory to output service codes
    -i, --import <items>    third party proto import path: e.g path1,path2,path3
    -e, --exclude <items>   files or paths in -p shall be excluded: e.g file1,path1,path2,file2
    -c, --client            add -c to output grpc client source codes
    -s, --server            add -s to output grpc server source codes
    -g, --gateway           add -g to output gateway router api source codes
    -d, --deepSearchLevel <number> 	add -d to parse swagger definition depth, default: 5
    

Simple

Simple:Generate js codes

matrix proto \
--proto ./examples/proto \
--output ./examples/output \
--import ./examples/proto_modules \
--exclude ./examples/proto_modules/google \
--javascript
--all

Simple:Generate d.ts codes

matrix proto \
--proto ./examples/proto \
--output ./examples/output \
--import ./examples/proto_modules \
--exclude ./examples/proto_modules/google \
--typescript
--all

Simple:Generate swagger json

grpc-gateway is a 3rd framework. We need a sub tool protoc-gen-swagger from this framework, to generate swagger json from proto files.

  • Gateway tool is built with golang. So install it first, download here.
  • Then setup GOPATH following this.
// install protoc-gen-swagger
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

matrix proto \
--proto ./examples/proto \
--output ./examples/output \
--import ./examples/proto_modules \
--exclude ./examples/proto_modules/google \
--swagger
--all

Simple:Generate grpc server codes

matrix grpc \
--proto ./examples/proto \
--output ./examples/output \
--import ./examples/proto_modules \
--exclude ./examples/proto_modules/google \
--server

Simple:Generate grpc client codes

matrix grpc \
--proto ./examples/proto \
--output ./examples/output \
--import ./examples/proto_modules \
--exclude ./examples/proto_modules/google \
--client

About

A variety of command-line tools are provided to help developers build a base microservice.

Resources

License

Stars

Watchers

Forks

Packages

No packages published