Skip to main content

BFF Scripts: Local & Remote Sync

BFF scripts are logic that runs on the platform. Common types include ENDPOINT (API handler), COMMON (shared utility functions), and HOOK (hooks attached to dataset operations). The CLI commands in this section revolve around local files + lock files for synchronization: you can pull scripts from the remote, edit them locally, and push them back, or create new ones locally and upload them.

Prerequisites: logged in with the correct App Code; the project has the BFF directory configured according to convention (the exact path is determined by the project template and bff-related configuration; check error messages for path hints if something goes wrong).

View remote scripts

rabetbase bff list
rabetbase bff list --type COMMON
rabetbase bff list --name getUserInfo

View details of a specific script (including full script content):

rabetbase bff detail --id <numeric-ID>

The ID comes from the output of bff list.

Check local vs. remote consistency: status

After modifying files, check whether they match what the lock file records and if anything hasn't been pushed:

rabetbase bff status

To also discover scripts that exist on the remote but not locally:

rabetbase bff status --remote

Pull from remote to local: pull

Pull platform scripts into your project (handles conflicts and updates the lock file):

rabetbase bff pull

Pull only a specific type or force an overwrite:

rabetbase bff pull --type ENDPOINT
rabetbase bff pull --force

Before your first collaboration, the team should agree on whether to "treat remote as source of truth and pull" or "treat local as source of truth and push" to avoid overwriting each other's changes.

Create a new local script: new

Generate a file from a template to save time writing boilerplate:

rabetbase bff new --type ENDPOINT --name myHandler

Type descriptions:

  • ENDPOINT: Externally exposed API handler scripts.
  • COMMON: Utility functions shared by other scripts.
  • HOOK: Hooks attached to a specific dataset operation. Typically requires specifying a dataset (--alias preferred; fall back to --datasetcode if unavailable) and hook-related parameters. Interactive mode will guide you through the selection.

For the full list of non-interactive parameters for HOOK, refer to rabetbase bff new --help.

Push local changes to remote: push

After editing locally:

rabetbase bff push

You can narrow the scope by type or function name; force an overwrite if you're certain:

rabetbase bff push --type ENDPOINT --name myHandler
rabetbase bff push --force

push is a high-risk write operation. Team conventions often require a review process or enforce riskLevel restrictions.

Delete a remote script and clean up locally: delete

rabetbase bff delete --target <lockKey-or-short-name>

This deletes the remote script and updates the lock file. The local file is moved to a trash-like directory (check the CLI output for implementation details). Always verify there are no production dependencies before deleting.

Difference from the old "bff save" in earlier docs

Older documentation may reference a single-file save command. The current CLI workflow is based on bff new + edit + bff push and bff pull, with sync state tracked via a lock file. If a tutorial still mentions bff save, refer to the subcommands listed in rabetbase bff --help instead.


Summary

  • list / detail: Inspect the remote.
  • status: Check consistency before syncing.
  • pull / push: Main sync workflow.
  • new: Scaffold a new script.
  • delete: High-risk operation. Use with caution.

For menus and code generation, see Code Generation & Menu.