0.0.26 • Published 5 months ago

@calljmp/cli v0.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Calljmp CLI

Secure backend-as-a-service for mobile developers. No API keys. Full SQLite control.

npm version GitHub license

šŸš€ Overview

Calljmp is a secure backend designed for mobile developers, providing:

  • āœ… Authentication via App Attestation (iOS) and Play Integrity (Android)
  • āœ… Full SQLite database access (no restrictions, run raw SQL)
  • āœ… Dynamic permissions for users & roles
  • āœ… React Native SDK for seamless integration

šŸ”¹ Website: calljmp.com
šŸ”¹ Follow: @calljmpdev


šŸ“¦ Installation

Install the CLI globally via npm:

npm install -g @calljmp/cli

or via yarn:

yarn global add @calljmp/cli

šŸ› ļø Setup & Usage

Most commands require current directory to be a project root directory when executing them. You can optionally supply a project root directory with --project <project-directory> flag.

1ļøāƒ£ Setup and link project

Add ignores, generate types, and install dependencies. It will also walk you through the login and linking process.

calljmp setup

2ļøāƒ£ Local development

Run the local development server to develop your backend locally:

calljmp start

If you want to run the local server in a different port, you can specify it with the --port flag:

calljmp start --port 8080

If you want to persist the data between restarts, you can specify the --persist-database flag:

calljmp start --persist-database

3ļøāƒ£ Managing database

Manage your SQLite schema and generate migrations:

calljmp database schema

You can reset the local database to its initial state with:

calljmp database reset

Pull the database schema and data from your cloud project to local database:

calljmp database pull

Apply migrations to the cloud database and local database:

calljmp database migrate

4ļøāƒ£ Deploy to Calljmp

Deploy your local changes to the cloud:

calljmp service deploy

Code generation

Generate TypeScript code for environment variables, database, and resources:

calljmp service generate

Environment variables

You can set environment variables in the .env file with CALLJMP_ prefix or without prefix in .service.env. In order to protect a value upon deployment and access outside of the service scope prepend key with SECRET_ prefix. The CLI will automatically load them when you run the commands.

For example:

.env:

CALLJMP_SOME_TOKEN = "not a secret token"
CALLJMP_SECRET_TOKEN = "encrypted secret token"

.service.env:

ANOTHER_TOKEN = "another public token"
SECRET_ANOTHER_SAFE_TOKEN = "encrypted another secret token"

Then in code you will have access to:

import { Service } from './service';

const service = Service();

service.get('/', async c => {
  // Evaluate access control to your service
  {
    console.debug(
      'Access',
      c.var.trusted,
      c.var.userId,
      c.var.platform,
      c.var.serviceId
    );

    if (!c.var.trusted && !c.env.DEVELOPMENT) {
      // Calljmp was not able to confirm the device and app integrity when the service was called.
      return c.json({ error: 'Unauthorized' }, 401);
    }

    if (!c.var.userId) {
      // User is not authenticated.
      return c.json({ error: 'Unathenticated' }, 401);
    }
  }

  // Access environment variables and secrets
  {
    console.debug('Variables', c.env.SOME_KEY, c.env.ANOTHER_KEY);
    console.debug(
      'Secrets',
      c.env.ACTUAL_SECRET_KEY,
      c.env.COMMON_VERY_SECRET_KEY
    );
  }

  // Access database and return query result
  {
    const result = await c.env.db.prepare('PRAGMA table_info(users)').run();
    return c.json({ result });
  }
});

export default service;

šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

šŸ’¬ Support & Community

If you have any questions or feedback:

0.0.26

5 months ago

0.0.25

5 months ago

0.0.24

5 months ago

0.0.23

5 months ago

0.0.22-preview

5 months ago

0.0.21-preview

6 months ago

0.0.20-preview

6 months ago

0.0.19-preview

6 months ago

0.0.18-preview

6 months ago

0.0.17-preview

6 months ago

0.0.16-preview

6 months ago

0.0.15-preview

6 months ago

0.0.14-preview

6 months ago

0.0.13-preview

6 months ago

0.0.12-preview

7 months ago

0.0.11-preview

7 months ago

0.0.10-preview

7 months ago

0.0.9-preview

7 months ago

0.0.8-preview

7 months ago

0.0.7-preview

7 months ago

0.0.6-preview

7 months ago

0.0.5-preview

7 months ago

0.0.4-preview

7 months ago

0.0.3-preview

7 months ago

0.0.2-preview

7 months ago

0.0.1-preview

7 months ago