Getting Started in 4 Minutes

Introduction

This guide will help you take Jumpjet for a test flight in 4 minutes (guaranteed!).

You will use Jumpjet to inject 2 variables into a sign-up microservice in node.js. We'll walk you through the required steps:

That's it!

We do realize your world is way more complex than Hello World. We've designed Jumpjet so you can start using it now on a small group of new variables and migrate the rest later (see FAQ: can I use Jumpjet for very few config variables and migrate the others later?)

List Your Variables

There are 2 variables in our sign-up microservice that should vary between our Dev and Prod environments:

  1. URL of the app's MongoDB database (string)

  2. Whether to require email verification for new sign-ups (boolean)

Log into Jumpjet, go to the Variables page and list those two variables. Leave the Default Value field empty. We will set their values at the environment level.

List Your Environments

Go to the Environments page and add your two environments: Dev and Prod.

Click on an environment name (ex: Dev) to manage all the variable values within it. It makes sense to point Dev to a local MongoDB instance and disable email verification so developers can work with less friction:

Variable values will be different under Prod, of course. There we may set DB_URL to mongodb0.myapp.com:27017 and REQUIRE_EMAIL_VERIFICATION to true.

Use the Jumpjet CLI Tool in Your Build

In the next section, we'll be doing things the node.js way and reading our variables from a .ENV file.

Let's use the Jumpjet CLI tool to create this .ENV file and inject the right value into it, based on the current environment. Create a template for an ENV file that contains Jumpjet placeholders - double curly brackets around the variables you manage in the Jumpjet UI. Here's one:

.ENV.template
DB_URL={{DB_URL}}
REQUIRE_EMAIL_VERIFICATION={{REQUIRE_EMAIL_VERIFICATION}}

It's magic time. Get the Jumpjet CLI tool and run the following command, instructing Jumpjet to pull your Dev configuration from the cloud and create a .ENV file with the right values:

# Get the tool
wget https://app.jumpjet.co/download/osx/jumpjet 
chmod +x jumpjet 

# Authenticate with the credentials from app.jumpjet.co
export JUMPJET_APIKEY=2a07f477d6dfcffc1a8bf9ce621873bce316d3519dab6ddad948f14bf0cf0054 
export JUMPJET_APPSLUG=default-de4d726513 

./jumpjet sub --env Dev -o .env .env.template 

We specified Dev as the environment name, so the result .ENV file will look like this:

.ENV
DB_URL=localhost:27017
REQUIRE_EMAIL_VERIFICATION=false

Access the Variables in Your Code

Node.js developers like to use dotenv to load .ENV file into the process's environment variables and access them. We'll do exactly that and log the variables at startup.

// Loads the .ENV file into process.env so we can access the variables
require('dotenv').config()

console.log('Sign up microservice started')
console.log('DB URL: %d', process.env.DB_URL)
console.log('Email verification required: %d', process.env.EMAIL_VERIFICATION_REQUIRED)

You're all set.

You can use the above process and put placeholders in any file (JSON, YAML), not just ENV.

Need help using Jumpjet? Drop us a line at hello@jumpjet.co.

Last updated