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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


atlassian-connect-express 5: add parameters to config.json


This article is based on the previous article.

You can find the source code for the article here.

You can watch the video for this article here.

In this article we will discuss how to add your own parameters to config.json file.

As you remember backend/config.json contains parameters which are passed to the application when the application is starting. These parameters are passed by developers or administrators, that is why these parameters are not hardcoded somewhere in the code, but are placed in the config.json file which is easy to edit.

You may need your own parameters if you introduce logic which depends on some switchers. In this case you can add the switchers to the config.json file. Or if you call some kind of Rest Api and the url of the Rest Api is different for development and production. In this case you can add the url of the Rest Api to the config.json. Or if you are connecting to some external application and you need to provide the user name and the token to connect to this system.

We will be changing the development section of config.json. The same can to be done to the production section. Here is our development section:

    "development": {
        "port": 3000,
        "errorTemplate": true,
        "store": {
            "adapter": "sequelize",
            "dialect": "sqlite3",
            "type": "memory"
        "localBaseUrl": ""

First, let’s make our app read the port and localBaseUrl parameters from environment variables:

"development": {
        "port": "$PORT",
        "errorTemplate": true,
        "store": {
            "adapter": "sequelize",
            "dialect": "sqlite3",
            "type": "memory"
        "localBaseUrl": "$APP_URL"

As you can see the port value will be taken from the PORT environment variable and the local base url from APP_URL environment variable.

Now let’s add new parameters to our config file. We will add a REST API url and credentials for our external app:

"development": {
        "port": "$PORT",
        "errorTemplate": true,
        "store": {
            "adapter": "sequelize",
            "dialect": "sqlite3",
            "type": "memory"
        "localBaseUrl": "$APP_URL",
        "restApiUrl": "",
        "externalApp" : {
            "username" : "myusername",
            "token": "mytoken"

I created the restApiUrl parameter which has just a string value and the externalApp parameter the value of which is a json. I could have also created these parameters as variables like the port and externalApp parameters, but for the sake of simplicity I will not do it.

Now let’s add some code to our application to read all these parameters:

http.createServer(app).listen(port, () => {
  console.log('App server running at ' + addon.config.localBaseUrl());
  console.log(`port: ${addon.config.port()}`)
  console.log(`localBaseUrl: ${addon.config.localBaseUrl()}`)
  console.log(`restApiUrl: ${addon.config.restApiUrl()}`)
  console.log(`externalApp: ${JSON.stringify(addon.config.externalApp())}`)

As you can see to read parameters you need just to call addon.confg.<the name of the parameter>().

The externalApp parameter we defined as json, that is why an object in json format is returned. And that is why we stringify the output to see the output in the terminal: JSON.stringify(addon.config.externalApp())

Let ‘s run our application. As a result we will have an error:

Error: listen EADDRINUSE: address already in use $PORT

It means that we did not initialize our environment variable PORT. Let’s initialize both the PORT and APP_URL variables:

export PORT=3000
export APP_URL=

Now let’s run our application again and here is the output:

pport: 3000
externalApp: {"username":"myusername","token":"mytoken"}

That is it. Now we can define our own parameters and read the parameters in our app.

Thank you for reading!

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.
Jun 04, 2021

Interesting content, thank you @Alexey Matveev 

AUG Leaders

Atlassian Community Events