Baqend CLI
The CLI (Command Line Interface) provides a simple way to:
- Register a Baqend account and start an app
- Deploy application assets (HTML, images, CSS, etc.)
- Register Baqend Code (modules and handlers)
The Baqend CLI can easily be installed globally with npm install -g baqend
(to get npm you just need to have Node.JS installed). Afterwards you can use the CLI
by typing baqend --help
in any folder.
PATH
system enviroment variable contains the global
npm bin path ($ npm bin -g
) to let npm installed commands work properly.The Baqend CLI is automatically shipped with our SDK. You can use the Baqend CLI directly in any npm script. Therefore add a Baqend script entry to the scripts section in your projects package.json
"scripts": {
"baqend": "baqend"
}
Afterwards you can type npm run baqend -- --help
--
are required to seperate the npm run arguments from the Baqend ones.Register, Login, and Logout
Before you can actually deploy assets and code you have to create a Baqend account.
The easiest way to use it is the baqend register
command.
If you already have an account, you are able login the CLI by typing
baqend login
.
These commands will save your credentials locally.
If you do not want so save your login credentials, you can skip the login step and provide the login credentials each time you deploy.
You can logout the Baqend CLI and remove all locally stored credentials by typing baqend logout
Usage With Community Edition
You can also use the CLI in combination with Baqend's free community edition. For logging into a self-hosted Baqend instance, you simply have to provide the connection URL instead of the app name when using the baqend login
command.
For example, you can connect to a local Baqend instance like so:
baqend login http://localhost:8080/v1
The trailing /v1
is required as it represents the API endpoint of your Baqend server.
Deployment
With the deploy
command, you can upload your static files and assets as well as Baqend Code (modules and handlers) to your Baqend app:
$ baqend deploy
Deploying Static Files
You can host the static files and assets of your web app on Baqend.
Therefore, move your working directory to your app root folder.
We expect you to have a folder named www
by default that is uploaded to the www
folder in Baqend Files and served as a website.
--file-dir
or -f
option to specify a directory:
baqend deploy --file-dir dist
.
The files are then hosted from Baqend. Read more about Baqend Hosting in the Hosting chapter.
Deploying Baqend Code
The CLI can additionally deploy your Baqend Code. Baqend code should be located in an folder named baqend
.
The following screenshot visualizes a typical project layout including Baqend code.

baqend
folder.
For example, baqend/firstModule.js
will be uploaded as firstModule
.
For each code handler you should create a folder named similar to the table it belongs to. Within the folder the files should be named:
baqend/<Table>/insert.js
for an onInsert handler
baqend/<Table>/update.js
for an onUpdate handler
baqend/<Table>/delete.js
for an onDelete handler
baqend/<Table>/validate.js
for an onValidate handler
Therefore baqend/User/insert.js
contains the insert handler code wich is invoked each time a new user object is inserted
to the User
table.
Read more about Baqend code in the Baqend Code chapter.
After deploying your app, you can open it by typing baqend open
or use the dashboard with baqend dashboard
.
Deploying Schema
You can download and upload your app schema as well. After downloading your schema, the CLI will create an own json file for each class in the baqend/schema
directory.
$ baqend schema download
When uploading your new schema, either only new fields are added to you schema and no fields will be deleted or the schema will be completly replaced, depending on wether you use the -F
option or not.
$ baqend schema upload
$ baqend schema upload -F
It's also possible to upload your new schema every time you're deploying your baqend code by adding the -S
option to the baqend deploy
command.
$ baqend deploy -S
TypeScript Support
The Baqend SDK itself comes with a TypeScript declaration file, which enables seamless integration into TypeScript and allows better code completion. The SDK comes with a dynamic API part, which is generated on the fly depending on your current schema. To make your TypeScript application work properly with this dynamic part you can generate the additional typings for your current schema with the CLI.
With baqend typings your-app-name
the CLI generates the TypeScript declaration file in the current folder.
You can then add the generated file to your tsconfig.json file.
You can update the generated file each time you have changed tables or fields in the Baqend Dashboard by just repeating this step.