Skip to content
/ csb Public

Adds a layer between your application and Contentstack, to provide some much-needed conveniences

License

Notifications You must be signed in to change notification settings

Dobefu/csb

Repository files navigation

Contentstack Bridge

CI Status Quality Gate Status Go Report Card

Adds a layer between your application and Contentstack, to provide some much-needed conveniences.

Tip

The complete documentation can be found at https://dobefu.github.io/csb/

Table Of Contents

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.

Configuration

Setting up the .env file

Configuration is done with a .env file. To start, copy the .env.example:

cp .env.example .env

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.

Alternatively, databases like MySQL are supported as well. A MariaDB database can quickly be spun up locally:

docker compose up -d

Usage

Database migration

When first starting the application, the database will be completely empty. To add all necessary tables and rows to the database, run the following command:

./csb migrate:db

This will create the necessary tables and rows in order for the application to work.

Remote sync

To synchronise all data from Contentstack, the following command can be used:

./csb remote:sync

This will perform a full synchronisation with the Contentstack data. This is meant to populate the database, and perform any computationally expensive operations ahead of time. Every subsequent time that the command is run, the sync will only process changes that have occured since the last sync.

If the sync needs to be restarted from scratch, the following command can be used:

./csb remote:sync --reset

About

Adds a layer between your application and Contentstack, to provide some much-needed conveniences

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project