CLI
Calljmp CLI is designed for mobile developers, offering powerful tools to manage backend services securely. With Calljmp, you can authenticate users, access databases directly, and manage dynamic user permissions, all within the mobile app environment.
Features:
- Local development: Test and develop your mobile backend locally.
- Deployment to Cloudflare: Deploy your backend services to the Cloudflare edge network.
- Environment management: Manage environment variables and secrets securely.
- SQL database access: Directly interact with your SQL database for schema management and data operations.
Installation
To get started with the Calljmp CLI, you need to install it globally via npm:
npm install -g @calljmp/cli
Once installed, you can verify the installation by running:
calljmp --version
Getting started
To initialize Calljmp in your project, navigate to your project directory and run the following command:
Before you can deploy your service, you must have a Calljmp account and be logged in to the Calljmp dashboard at dash.calljmp.com.
If you are using a monorepo, you can supplement the --project
flag with the
path to your project. For example, calljmp setup --project apps/my-app
.
calljmp setup
This command will help you configure your project, add necessary ignores, generate types, and guide you through the login and linking process.
Local development
Run the local development server to test your service locally:
- Name
module
- Type
- string
- Default value
- ./src/service
- Description
Path to the module directory containing your service code in
main.ts
.
- Name
port
- Type
- number
- Default value
- 8787
- Description
Port to run the local server on.
- Name
persist-database
- Type
- boolean
- Default value
- false
- Description
Persist the database between runs.
calljmp start
Manage database
Easily manage your SQLite schema and migrations using the following commands:
-
View and update your local database schema:
calljmp database schema
Inspect or modify your local SQLite schema and generate migration files.
-
Reset your local database:
calljmp database reset
This command will erase all local data.
-
Synchronize your local database with the cloud:
calljmp database pull
Pull the latest schema and data from your cloud project into your local database.
-
Apply migrations to both local and cloud databases (
--remote
flag):calljmp database migrate
Execute all pending migrations on both your local and cloud databases.
Service access
Retrieve a short-lived access token for your service. This token is used to authenticate requests to your service.
calljmp service access
Service deployment
Deploy your local changes to the cloud:
calljmp service deploy
Code generation
Generate TypeScript code for your environment variables, database, and other resources.
calljmp service generate
The generate
command is automatically run when you run calljmp setup
. You
can also run it manually to update your types after making changes to your
database or environment variables.
Environment variables
Environment variables are managed in the .env
and .service.env
files. You can add your environment variables there, and they will be available in your code.
Both .env
and .service.env
can be split per environment. For example, you
can have .env.development
, .env.production
, and
.service.env.development
, .service.env.production
. The CLI will
automatically pick the right file based on the environment you are running in.
CALLJMP_SOME_TOKEN = "not a secret token"
CALLJMP_SECRET_ENCRYPTED_TOKEN = "encrypted secret token"
To add a secret prepend SECRET_
to a variable name. This will encrypt the variable and make it available in your code without the prefix.
import { CloudService } from './service'
class AppCloudService extends CloudService {
protected override onRequest(request: Request): Response | Promise<Response> {
console.debug('Variables:', this.variables.someToken)
console.debug('Secrets:', this.secrets.encryptedToken)
}
}
export default new AppCloudService()
Secrets
You can manage your secrets using the calljmp secrets
command. To list all secrets, run:
calljmp secrets list
Add a secret
Secrets are automatically added through environment variables. To add a secret explicitly, use the following command:
- Name
name
- Type
- string
- Description
The name of the secret to add. If not specified, it will prompt you to enter a name.
- Name
value
- Type
- string
- Description
The value of the secret to add. If not specified, it will prompt you to enter a value.
calljmp secrets add [name] [value]
Delete a secret
To delete a secret, you can use the following command:
- Name
name
- Type
- string
- Description
The name of the secret to delete. If not specified, it will prompt you to select secrets to delete.
calljmp secrets delete [name]