Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

atlassian-connect-express 7: working with Postgres


In this article we will talk how to connect Postgres to our app.

The code will be based on this article.

You can find the source code for the article here.

You can find a video for this article here.

Our app by default stores information about all clients who installed our app. By default this data is stored in an in-memory database which means if we restart our app all registration data of our clients will be lost. It can be acceptable during development but it is definitely not acceptable during production mode.

That is why in this article we will see how to connect our app to Postgres.

I created a Postgres database with the following command:

docker run -p 5432:5432 --name tutorial_db -e POSTGRES_PASSWORD=password -d postgres

And then I created a database called “app”:

Screenshot 2021-05-24 at 11.05.53.png

Right now we have the following configuration for our database in the backend/config.json file:

"store": {
            "adapter": "sequelize",
            "dialect": "sqlite3",
            "type": "memory"

As you can see we use an in-memory database. Now let’s change the configuration to this one:

"store": {
            "type": "postgres",
            "url": "$DATABASE_URL"

Now we need to set the $DATABASE_URL parameter. We can do it by setting the DATABASE_URL environment variable, but for the sake of simplicity I will replace $DATABASE_URL with a database url:

 "url": "postgres://postgres:password@localhost:5432/app"

Now we need to add the pg dependency to our app and install it:

npm install --save-dev pg

Now let’s start our app:

npm start

It started successfuly.

If you look at the app database you will see that a new table called AddonSettings has been created:

Screenshot 2021-05-24 at 11.11.33.png

Right now the table is empty. Let’s install our app to Bitbucket and have a look what will change.

Here is how the table looks after I installed my app:

Screenshot 2021-05-24 at 11.14.11.png

You can see that we have a new line with the “clientInfo” key. This line was added by atlassian-connect-express and contains information about the client which lets atlassian-connect-express identify and validate requests from the client.

That is all for the article. See you next time.

1 comment


Log in or Sign up to comment
M Amine
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2021

Good information, thank you @Alexey Matveev 

AUG Leaders

Atlassian Community Events