Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/panacloud/cli
Panacloud Command Line Interface (CLI) uses the design-first approach for developing APIs. It generates Modern Multi-Tenant Serverless Cloud API infrastructure, mocks, stubs, tests, and stages using CDK. GraphQL schemas and OpenAPI specifications are used to implement the design-first approach.
https://github.com/panacloud/cli
aws cdk graphql openapi serverless
Last synced: 7 days ago
JSON representation
Panacloud Command Line Interface (CLI) uses the design-first approach for developing APIs. It generates Modern Multi-Tenant Serverless Cloud API infrastructure, mocks, stubs, tests, and stages using CDK. GraphQL schemas and OpenAPI specifications are used to implement the design-first approach.
- Host: GitHub
- URL: https://github.com/panacloud/cli
- Owner: panacloud
- Created: 2021-08-31T15:59:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T20:00:27.000Z (over 1 year ago)
- Last Synced: 2024-10-30T18:08:16.149Z (15 days ago)
- Topics: aws, cdk, graphql, openapi, serverless
- Language: TypeScript
- Homepage:
- Size: 7.89 MB
- Stars: 25
- Watchers: 10
- Forks: 6
- Open Issues: 112
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@panacloud/cli.svg)](https://www.npmjs.org/package/@panacloud/cli)
[![Downloads/week](https://img.shields.io/npm/dw/@panacloud/cli.svg)](https://www.npmjs.org/package/@panacloud/cli)
[![License](https://img.shields.io/npm/l/@panacloud/cli.svg)](https://github.com/panacloud/cli/blob/master/package.json)# Panacloud Command Line Interface (CLI)
[Panacloud CLI Discord Channel](https://discord.gg/uQ7vPXuu5v)
In a recent [report](https://venturebeat.com/2021/12/09/report-75-of-devs-indicate-that-participating-in-api-economy-is-top-priority/) 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](https://graphql.org/) [schema](https://graphql.org/learn/schema/) that has been augmented with Panacloud directives and creates [infrastructure as code (IaC)](https://acloudguru.com/blog/engineering/cloudformation-terraform-or-cdk-guide-to-iac-on-aws), mock lambdas, tests, and scaffolding for genuine lambdas that include business logic and database requests. It makes use of [AWS CDK](https://aws.amazon.com/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](img/cli.png "CLI Diagram")
The generated serverless SaaS API project supports multi-tenant usage based billing and monetering and is closely integrated with the [Panacloud portal](https://www.panacloud.org). 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](https://github.com/panacloud-modern-global-apps/full-stack-serverless-cdk) to help you to learn AWS CDK.
Before getting started you need to install the following packages and libraries:
1. Install [Node.js](https://nodejs.org/en/)
2. Install [AWS CLI Version 2.x](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)
3. Install [AWS CDK Version 2](https://docs.aws.amazon.com/cdk/latest/guide/work-with-cdk-v2.html)
4. Install Globally [TypeScript](https://www.typescriptlang.org/download)Before starting your API project learn to develop APIs using this [bootcamp](https://github.com/panacloud/bootcamp-2021#part-3-introduction-to-serverless-and-cloud-computing-using-cdk) and [learning API repo](https://github.com/panacloud-modern-global-apps/api-design-prototype-testing)
The first step in developing a GraphQL [schema](https://dgraph.io/blog/post/designing-graphql-schemas/) 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](https://docs.aws.amazon.com/cdk/latest/guide/aspects.html).
Now Globally Install Panacloud CLI:
npm install @panacloud/cli -g
* [Panacloud Command Line Interface (CLI)](#panacloud-command-line-interface-cli)
* [Getting Started](#getting-started)
* [Usage](#usage)
* [Panacloud Commands](#panacloud-commands)
* [Project NPM Commands](#project-npm-commands)# Getting Started
Please read these articles to understand the approach:[API-First, API Design-First, or Code-First: Which Should You](https://blog.stoplight.io/api-first-api-design-first-or-code-first-which-should-you-choose)
[Schema-First GraphQL: The Road Less Travelled](https://blog.mirumee.com/schema-first-graphql-the-road-less-travelled-cf0e50d5ccff)
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](https://graphql.org/learn/schema/)
1. Now we will generate an AWS CDK project using the panacloud cli.
```
mkdir my_user_apicd 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](https://github.com/panacloud/cli/tree/main/tutorials) for a detailed introduction to the project generated by CLI.
# Usage
```sh-session
$ 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]`](#panacloud-client-file)
* [`panacloud config:customData`](#panacloud-configcustomdata)
* [`panacloud config:memory [QUERY_NAME] [MEMORY_SIZE]`](#panacloud-configmemory-query_name-memory_size)
* [`panacloud config:mock [QUERY_NAME]`](#panacloud-configmock-query_name)
* [`panacloud config:stage [STAGE_NAME]`](#panacloud-configstage-stage_name)
* [`panacloud config:timeout [QUERY_NAME] [TIMEOUT]`](#panacloud-configtimeout-query_name-timeout)
* [`panacloud help [COMMAND]`](#panacloud-help-command)
* [`panacloud init`](#panacloud-init)
* [`panacloud login`](#panacloud-login)
* [`panacloud merge`](#panacloud-merge)
* [`panacloud status`](#panacloud-status)
* [`panacloud update`](#panacloud-update)## `panacloud client [FILE]`
describe the command here
```
USAGE
$ panacloud client [FILE]OPTIONS
-h, --help show CLI help
```_See code: [src/commands/client.ts](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/client.ts)_
## `panacloud config:customData`
Upate panacloudconfig.json
```
USAGE
$ panacloud config:customDataOPTIONS
-f, --false Set is_custom false
-h, --help show CLI help
-t, --true Set is_custom true
```_See code: [src/commands/config/customData.ts](https://github.com/panacloud/cli/blob/v0.0.9/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](https://github.com/panacloud/cli/blob/v0.0.9/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](https://github.com/panacloud/cli/blob/v0.0.9/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](https://github.com/panacloud/cli/blob/v0.0.9/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](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/config/timeout.ts)_
## `panacloud help [COMMAND]`
display help for panacloud
```
USAGE
$ panacloud help [COMMAND]ARGUMENTS
COMMAND command to show help forOPTIONS
--all see all commands in CLI
```_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.3/src/commands/help.ts)_
## `panacloud init`
Generates CDK code based on the given schema
```
USAGE
$ panacloud initOPTIONS
-d, --database=(DynamoDB (NoSQL)|Neptune (Graph)|Aurora Serverless (Relational))
-h, --help show CLI help
-t, --test
```_See code: [src/commands/init.ts](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/init.ts)_
## `panacloud login`
Login into your Panacloud Portal Account
```
USAGE
$ panacloud login
```_See code: [src/commands/login.ts](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/login.ts)_
## `panacloud merge`
Merge multiple GraphQL schema in one
```
USAGE
$ panacloud mergeOPTIONS
-h, --help show CLI help
```_See code: [src/commands/merge.ts](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/merge.ts)_
## `panacloud status`
describe the command here
```
USAGE
$ panacloud statusOPTIONS
-h, --help show CLI help
```_See code: [src/commands/status.ts](https://github.com/panacloud/cli/blob/v0.0.9/src/commands/status.ts)_
## `panacloud update`
Updates the Generated Code.
```
USAGE
$ panacloud updateOPTIONS
-h, --help show CLI help
```_See code: [src/commands/update.ts](https://github.com/panacloud/cli/blob/v0.0.9/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)](https://docs.aws.amazon.com/cdk/latest/guide/home.html) 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](https://docs.aws.amazon.com/cdk/latest/guide/aspects.html) 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](https://www.panacloud.org/) and [protocol](https://github.com/panacloud/protocol) complements this CLI and facilitates the API developer to:
1. [Tokenize](https://cryptonews.com/news/tokenization-crowdfunding-in-the-era-of-cryptocurrency-and-b-10972.htm) the APIs and raise funding for API development.
2. Document the developer ownership of the API by issuing you an [NFT](https://ethereum.org/en/nft/).
3. Market the APIs to the application developers in the API bazaar/store.
4. Create a decentralized [autonomous organization (DAO)](https://ethereum.org/en/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](https://variant.fund/writing/the-ownership-economy-crypto-and-consumer-software).
8. 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 ReleaseExpected 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.