0.0.11 • Published 2 years ago

@panacloud/cli v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

oclif Version Downloads/week License

Panacloud Command Line Interface (CLI)

Panacloud CLI Discord Channel

In a recent report 75% of developers indicate that participating in API economy is ‘top priority’. Panacloud is an unified API development, fundraising, and ownership economy platform. It provides services, libraries, tools, and frameworks for developing totally open multi-tenant, serverless cloud services with integrated multi-tenant billing, crowdfunding, and ownership economy constructs. This allows developers to concentrate solely on creating specialised code related to their domain, leaving the rest to the Panacloud platform and services. This model has the potential to disrupt both the software and venture investment industries and making the API developers rich and owners of their own destiny and unicorn startups.

Panacloud CLI accelerates the building of modern multi-tenant serverless SaaS APIs. The CLI applies the design-first paradigm and implements the best practices for designing GraphQL APIs using public cloud serverless and infrastructure as code technologies. The CLI takes a GraphQL API schema that has been augmented with Panacloud directives and creates infrastructure as code (IaC), mock lambdas, tests, and scaffolding for genuine lambdas that include business logic and database requests. It makes use of AWS CDK for IaC. It now only supports AWS, TypeScript and GraphQL, but future versions will also support Azure and Google Cloud, OpenAPI and other languages as well.

CLI Flow

The generated serverless SaaS API project supports multi-tenant usage based billing and monetering and is closely integrated with the Panacloud portal. The developer just needs to write the specific code required by the Multi-Tenant SaaS project. This greatly reduces custom developer coding and increases speed to market. GraphQL and Open REST APIs can be built by using the Panacloud CLI. The APIs may use Graph or Relational databases, etc.

We have also published detailed Tutorials to help you to learn AWS CDK.

Before getting started you need to install the following packages and libraries:

  1. Install Node.js
  2. Install AWS CLI Version 2.x
  3. Install AWS CDK Version 2
  4. Install Globally TypeScript

Before starting your API project learn to develop APIs using this bootcamp and learning API repo

The first step in developing a GraphQL schema for your APIs. Once you have built your GraphQL schema and enhanced it with Panacloud directives, we will now use this CLI to develop the serverless cloud APIs.

The code generated by the CLI will consist of two parts:

  1. Code that will be managed and updated by the CLI. As we add and update the API schema, we will update the generated code using the CLI.
  2. Code that is editable by the API developer and is contained in the editiable_src directory. This code code contains the buisiness logic and is edited and updated by the developer.

Note: The developer can also modify and add the IaC CDK code by using CDK aspects.

Now Globally Install Panacloud CLI:

npm install @panacloud/cli -g

Getting Started

Please read these articles to understand the approach:

API-First, API Design-First, or Code-First: Which Should You

Schema-First GraphQL: The Road Less Travelled

In order to start learning to develop Serverless GraphQL APIs we have developed a very simple schema in the user.graphql file at the root of this tutorial.

You can learn how to develop GraphQL schemas from the schema official documentation

  1. Now we will generate an AWS CDK project using the panacloud cli.

    mkdir my_user_api
    
    cd my_user_api
    
    panacloud init
  2. On the command promt answer the question:

    GraphQL Schema File Path? ../user.graphql
    API Name? MyUserAPI
    Select Database? Neptune (Graph) 
    Select Query Language? Gremlin

    Now the MyUserAPI code is generated and available in the my_user_api directory.

Please review tutorials for a detailed introduction to the project generated by CLI.

Usage

$ npm install -g @panacloud/cli
$ panacloud COMMAND
running command...
$ panacloud (-v|--version|version)
@panacloud/cli/0.0.9 darwin-arm64 node-v16.13.2
$ panacloud --help [COMMAND]
USAGE
  $ panacloud COMMAND
...

Panacloud Commands

panacloud client [FILE]

describe the command here

USAGE
  $ panacloud client [FILE]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/client.ts

panacloud config:customData

Upate panacloudconfig.json

USAGE
  $ panacloud config:customData

OPTIONS
  -f, --false  Set is_custom false
  -h, --help   show CLI help
  -t, --true   Set is_custom true

See code: src/commands/config/customData.ts

panacloud config:memory [QUERY_NAME] [MEMORY_SIZE]

Upate panacloudconfig.json

USAGE
  $ panacloud config:memory [QUERY_NAME] [MEMORY_SIZE]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/memory.ts

panacloud config:mock [QUERY_NAME]

Upate panacloudconfig.json

USAGE
  $ panacloud config:mock [QUERY_NAME]

OPTIONS
  -f, --false  Set is_mock false
  -h, --help   show CLI help
  -t, --true   Set is_mock true

See code: src/commands/config/mock.ts

panacloud config:stage [STAGE_NAME]

Upate panacloudconfig.json

USAGE
  $ panacloud config:stage [STAGE_NAME]

OPTIONS
  -a, --add     Add New Stage
  -h, --help    show CLI help
  -r, --remove  Remove Stage

See code: src/commands/config/stage.ts

panacloud config:timeout [QUERY_NAME] [TIMEOUT]

Upate panacloudconfig.json

USAGE
  $ panacloud config:timeout [QUERY_NAME] [TIMEOUT]

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/timeout.ts

panacloud help [COMMAND]

display help for panacloud

USAGE
  $ panacloud help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

panacloud init

Generates CDK code based on the given schema

USAGE
  $ panacloud init

OPTIONS
  -d, --database=(DynamoDB (NoSQL)|Neptune (Graph)|Aurora Serverless (Relational))
  -h, --help                                                                        show CLI help
  -t, --test

See code: src/commands/init.ts

panacloud login

Login into your Panacloud Portal Account

USAGE
  $ panacloud login

See code: src/commands/login.ts

panacloud merge

Merge multiple GraphQL schema in one

USAGE
  $ panacloud merge

OPTIONS
  -h, --help  show CLI help

See code: src/commands/merge.ts

panacloud status

describe the command here

USAGE
  $ panacloud status

OPTIONS
  -h, --help  show CLI help

See code: src/commands/status.ts

panacloud update

Updates the Generated Code.

USAGE
  $ panacloud update

OPTIONS
  -h, --help  show CLI help

See code: src/commands/update.ts

Project NPM Commands

Once the project is generated you may run the following npm scripts

  • npm run deploy-dev Deploy Development Stage
  • npm run deploy-prd Deploy Production Stage
  • npm run destroy-dev Destroy Development Stage
  • npm run destroy-prd Destroy Production Stage
  • npm run test-dev Run Tests for the Development Stage
  • npm run test-prd Run Tests for the Production Stage

Details about the Project Generated by the CLI

The CLI generates project for Multi-Tenant Serverless API development with AWS Cloud Development Kit (CDK) using TypeScript. It comes with all the necessary code to develop and deploy a Serverless GraphQL API in the AWS Cloud. This includes the provisioning of cloud infrastructure in code and Serverless stubs where developers may easily include their business logic. The project also provides pre-built mock lambda functions and unit tests to test your deployed APIs.

The project code may be conceptually divided into two parts:

  1. The code that is generated by the Panacloud CLI, and will continuously be updated by the CLI as your API schema evolves. If the developer edits and updated this code, it will be overwritten next time the schema is updated and Panacloud CLI update command is given.
  2. The code that the developer edits and updates and contains the business logic for the APIs. This code is contained in the editable_src/ directory.

It is highly recommended that the developer only edit and update the code contained in the editable_src/ directory because the rest of the code is generated and updated by the Panacloud CLI.

The generated project code includes the mock lambdas contained in the mock_lambda directory in the root project folder. Typically, the developer will write business logic in the stub lambdas contained in the editable_src/lambdas/ directory. The configuration contained in the editable_src/panacloudconfig.json file decides which lambda the APIs will call. Therefore, the project may be using mock lambdas in some calls and the real stub lambdas in other calls. This flexibility allows the developer to seamlessly transition from mock APIs towards real APIs, without the API users and testers even noticing it. Also, the mock APIs may be deployed right away.

The API CDK stack (cloud infrastructure in code) is generated by the Panacloud CLI panacloud init command given the API schema. API development is an iterative process, therefore when the developer updates the API schema in the editable_src/graphql/schema/ directory and runs the panacloud update command the project's CDK code is updated. Given this cycle, most of the CDK stack is generated and updated by the Panacloud CLI. However, the developer has the flexibility to add and update the CDK stack by adding and updating visitors in the editable_src/aspects/ directory. The Panacloud framework uses Aspects to enhance generated constructs and add cloud constructs written by the API developers.

The editable_src/ directory contains all the code which the developer edits.

The editable_src/lambdas/ directory contains all the lambda stubs where the developer writes the business logic.

The editable_src/panacloudconfig.json file tells the Panacloud framework which lambda functions to call.

The editable_src/aspects directory contains all the CDK code which the developer adds to the project CDK stack.

The cdk.json file tells the CDK Toolkit how to execute your app.

The Panacloud Dapp and Protocol Complements the CLI

The Panacloud Dapp and protocol complements this CLI and facilitates the API developer to:

  1. Tokenize the APIs and raise funding for API development.
  2. Document the developer ownership of the API by issuing you an NFT.
  3. Market the APIs to the application developers in the API bazaar/store.
  4. Create a decentralized autonomous organization (DAO) for the APIs for governance in which the API token holders i.e. developer, investors, and users can participate.
  5. Monitor APIs and do multi-tenant billing and clearing on the Ethereum blockchain using smart contracts.
  6. Issue tokens to API early adopters and users to incentivize them to subscribe and use the APIs and become a participant in the Owership Economy.
  7. Allow the stakeholders to cash out whenever they require liquidity by selling API tokens.

The Panacloud CLI Roadmap

First Public Release

Release Date: December 25, 2021

Functionality:

  1. DynamoDB
  2. Neptune & AuroraDB
  3. Microservice dirrective
  4. Multiple stacks
  5. MockData & MockLambda
  6. panacloud status
  7. panacloud client

Second Release

Expected Date: January 15, 2022

Functionality:

  1. API Tests
  2. Async Dirrective
  3. Nested Resolver
  4. Return Type ( Issues with DynamoDB & Neptune )

Third Release

Expected Date: Feburary 1, 2022

Functionality:

Multi-Tenant monetering and billing data live streamed to Amazon Timestream Database deployed in Panacloud AWS Account.

Fourth Release

Expected Date: March 1, 2022

Functionality: Basic OpenAPI speficication support.