CLI Command Reference
The create
command generates barebones Cube app.
$ cubejs create APP-NAME -d DB-TYPE [-t TEMPLATE]
Parameter | Description | Values |
---|---|---|
-d, --db-type <db-type> | Preconfigure Cube app for selected database. | postgres , mysql , athena , mongobi , bigquery , redshift , mssql , clickhouse , snowflake , presto , druid |
-t, --template <template> | Framework running Cube backend. | docker (default), express , serverless , serverless-aws |
Create app called demo-app
using default (docker
) template and mysql
database:
$ cubejs create demo-app -d mysql
Create app called demo-app
using express
template and mysql
database:
$ cubejs create demo-app -t express -d mysql
To define configuration you should use cube.js
configuration file. See
available options.
The server
command starts Cube in production mode.
Default start:
$ cubejs server
With debug information:
$ cubejs server --debug
$ cubejs server
The generate
command helps to build data schema for existing database tables.
You can only run generate
from the Cube app directory. This command requires an active database connection.
$ cubejs generate -t TABLE-NAMES
Parameter | Description | Values |
---|---|---|
-t, --tables <tables> | Comma delimited list of tables to generate schema for. | TABLE-NAME-1,TABLE-NAME-2 |
Generate schema files for tables orders
and customers
:
$ cubejs generate -t orders,customers
The token
command generates a JWT Cube token. It either uses the value of the
CUBEJS_API_SECRET
environment variable or provided value with -s
flag. You
can only run token
command from the Cube app directory.
Use these manually generated tokens in production with caution.
Please
refer to the Security Guide for production
security best practices.
$ cubejs token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR -u BAZ=QUX
Parameter | Description | Example |
---|---|---|
-e, --expiry | Token expiry. Set to 0 for no expiry (default: "30 days") | 1 day , 30 days |
-s, --secret | Cube app secret. Also can be set via environment variable CUBEJS_API_SECRET | - |
-p, --payload | Token Payload | foo=bar , userId=2 |
-u, --user-context | Token USER_CONTEXT Payload | baz=qux , companyId=5 |
Generate token with 1 day expiry and payload { 'appId': 1, 'userId': 2 }
:
$ cubejs token -e "1 day" -p appId=1 -p userId=2
The typegen
command generates type declarations from a Cube API. It requires
both an API URL and a valid JWT for the API.
The API URL should be in the format http://<HOST>/cubejs-api/v1
. You should
run the typegen
command from a frontend project that uses
@cubejs-client/core
.
Usage
$ cubejs typegen API_URL --token TOKEN
Flags
Parameter | Description | Example |
---|---|---|
--token | A valid JWT for the provided API_URL | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ... |
Example
Generate types for a locally running Cube deployment:
$ cubejs typegen http://localhost:4000/cubejs-api/v1 --token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ...
Did you find this page useful?