Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Mohammed Amine Community Leader Jun 03, 2021

Good information, thank you @Alexey Matveev _Appfire_ 


Log in or Sign up to comment
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

131 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you