Getting Started
It’s pretty easy to set up the Contentstack Bridge.
Let’s walk through the steps that are needed to set it up.
Installation steps
Getting the program binary
There’s two ways to get the application binary.
One way is to build it locally.
Instructions on how to do this can be found on Building.
Alternatively, pre-built binaries can be found on the releases page on GitHub.
Once you have a csb
binary, you can verify that it works by running ./csb --help
.
If this command outputs a help menu, you can move on to the next step.
Configuring the .env file
For the application to be able to communicate with Contentstack and access its own database, a .env
file is required.
An example .env
file can be found in the GitHub repository.
Once the .env
file has been configured, you can validate it by running ./csb check:health
.
For more information about the possible configuration options, please see the Configuration options page.
Populating the database
Now that the application is configured, we can create the necessary database tables.
This can very easily be done by running ./csb migrate:db
.
Once this is done, all of the database tables will be set up and ready to go.
Synchronising the Contentstack data
Now that we have a database and tables, we need to populate the data.
We can do this by running ./csb remote:sync
.
This will synchronise the remote data into the database.
This is needed for the built-in API to work, among other things.
This command should also be ran periodically, to keep the data up-to-date.
When run again, the sync will continue where it left off,
so only the initial synchronisation will be a heavy operation.
Subpages
Building instructions for the application
Configuring the Contentstack Bridge
An overview of all possible configuration options
Subsections of Getting Started
Building
To build the application, simply run go build
.
This will create a new file, called csb
. Running it now will throw an error,
since there is no configuration yet.
Instructions on how to configure the application can be found on the Configuration page.
Configuration
Setting up the .env file
Configuration is done with a .env
file. To start, copy the .env.example
:
An example .env
file can also be found in the GitHub repository.
Contentstack credentials
The Contentstack credentials can be obtained from the Contentstack settings.
To reach the settings, go to your stack and click on the settings icon from the left sidebar.
The API Key (CS_API_KEY
) can be found on this page.
For the delivery token (CS_DELIVERY_TOKEN
), click on “Tokens” in the settings page.
If no delivery token exists, please create one by clicking on the top right button first.
Once you have a delivery token, you can click on it, and find it in the field “Delivery Token”.
The region (CS_REGION
) can be found directly in the URL.
It should look like <REGION>-app.contentstack.com
. The <REGION>
here is the region you need to use.
if the URL is app.contentstack.io
, the region will be us
.
Database credentials
When testing the application locally, the DB_*
variables can be left as-is.
This will create a file called db.sqlite3
. This can be handy for local testing.
For production use, databases like MySQL and Postgres are supported as well.
For testing, alternative databases can quickly be spun up locally:
Configuration options
Key | Example value | Description |
---|
CS_API_KEY | - | The API key for the Contentstack stack |
CS_DELIVERY_TOKEN | - | The Contentstack delivery token, used to fetch content |
CS_MANAGEMENT_TOKEN | - | The Contentstack management token, mainly used when creating content types in the CLI |
CS_BRANCH | main | The branch of the Contentstack stack to use |
CS_REGION | us / eu / azure-na / azure-eu | The region your Contentstack is located in. Visit Configuration for more information |
DB_CONN | file:db.sqlite3 | The database connection string |
DB_TYPE | sqlite3 / mysql / postgres | The type of the database to connect to |
DEBUG_AUTH_BYPASS | true / 1 | DEBUG: Disable authentication checks in the API server |