1.1.0 • Published 4 years ago

@pratiko-framework/cli v1.1.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

Pratiko

Pratiko - a Progressive Event-Driven Microservices Framework

Installation

sudo yarn global add @pratiko-framework/cli

You can also use NPM sudo npm install --global @pratiko-framework/cli

Usage

The Pratiko-cli is a tool to help out during the early development workflow, with commands to scaffold repository and deal with chores such as dockerization.

Start a new module with:

pratiko start Foo

cd Foo

This will create a new repository for your module

+ Foo/
+     .git
+     module.ptk.yaml

At this point, we recomend you to fulfill the module.ptk.yaml config file with information that will be useful in the next steps. Open it and write:

module_name: Foo

http_port: 9090

broker:
  name: broker
  port: 4222
  cluster_id: 'foo-broker'
  monitoring: false

db:
  config_file: ./db.ts
  docker_image: mongo:4.2.3-bionic
  packages:
    dependencies:
      - mongodb: ^3.5.5
    dev_dependencies:
      - '@types/mongodb': ^3.5.2

In the above example, we adopted MongoDB as our module's db. We set the mongo:4.2.3-bionic docker image to be injected in the docker-compose.yaml files in the components (more in the next section). We also defined the packages used, both dependencies and dev_dependencies, which will be added to the package.json file, accordingly. Finally, we let you configure the connection you way, informing a config_file to be used. That file will simply be copied to the components when you run the next command.

Now create a HTTP-responsible component, the Diplomat, with

pratiko create Diplomat

During the execution of this command, pratiko will create a directory to contain Diplomat files, such as

  • package.json, which will be inhanced with the MongoDB dependencies
  • src/index.ts, the entrypoint of the component
  • src/db.ts, the given config file for the database
  • Dockerfile, exposing the http_port defined (default: 9090)
  • docker-compose.yaml, containing configuration for
    • diplomat,
    • broker,
    • db
  • dev toolbelt files, a scaffold with configurations for
    • ESLint & Prettier for Linter rules
    • Jest for testing
    • Nodemon for hot reload the component

So the repository now looks like this:

Foo/
    .git
    module.ptk.yaml
+   Diplomat/
+       Dockerfile
+       docker-compose.yaml
+       .eslintrc.js
+       jest.config.js
+       nodemon.json
+       package.json
+       .prettierrc.js
+       src/
+           index.ts
+           db.ts
+       tsconfig.json

Now, the Diplomat is ready to receive some code! Check details in the Pratiko Guide.

The usage for de Meerkat is the same, just run pratiko create Meerkat instead of pratiko create Diplomat