Simplify Parse Server Cloud Code with Environment Variables in SashiDo

Marian Ignev

We are thrilled by all of the excitement that we see around Parse Server and Cloud Code development. We have seen many Cloud Code success stories, and at the same time challenges, for the Parse and SashiDo developers.

Today I would like to tell you about one significant addition to the SashiDo Platform, the Environment Variables, and the new Cloud Code Development Model.

Environment Variables

Every developer desires to build code that can be used in more than one environment. To do this in a clean and reusable fashion, the code should be able to accept configuration values at runtime. The configuration values customize the environment for the code: service credentials, custom URLs, file paths, and so forth. For example, many projects have distinct configurations for their development, test, and production environments.

In brief, using the Environment Variables is the best approach to design your code to work like an appliance.

Check out the 12factor config if you're interested in this field.

Parse.Config vs Environment Variables

Many of you who have some experience with Parse would say: "We have the Parse.Config, why we need another way to configure our apps?"

Yes, this is almost correct, but not really. Parse.Config was built mainly for configuring the Front-end side of your applications, for things like feature flagging, changing the look and feel settings or managing some contact information.

Parse.Config is a fantastic way to configure your application on the fly, but there few issues that make the Parse.Config inappropriate for every case. For example, every setting in the Parse.Config is public readable, in other words, any sensitive data should not be stored there!

All of this means that you need some secure way to store your credentials for Twilio, Stripe, Mailgun or any of the services you use in the Cloud Code.

In brief, the Environment Variables are the Parse.Config alternative for configuring the Back-end part of your application securely.

How to use the Environment Variables in the app's Cloud Code

Well, since the Environment Variables are very popular and they are used almost everywhere, NodeJS supports them as well. Let me give you an example of how the Environment Variables change your code.

Configuring Mailgun without Environment Variables

var mg = mailgun.client({
  username: 'api',
  key: "some_hardcoded_Key",
  public_key: "some_hardcoded_Public_Key"
});

And here is how the code will look like with Environment Variables.

var mg = mailgun.client({
  username: 'api',
  key: process.env.MAILGUN_API_KEY,
  public_key: process.env.MAILGUN_PUBLIC_KEY
});

As you can see in the first example, the code has the hardcoded credentials which make it not portable and insecure.

Setup your Environment Variables in the SashiDo's Dashboard

From the example above you already know how to use the Environment Variables in your application's Cloud Code. Adding them to the app environment is straightforward too. You only need to go to: Application -> Runtime -> Environment Variables

environment-variables-in-sashido-dashboard

When you're done click on the Save & Deploy button, and that's it! :)

Fin

Environment Variables bring a new level of simplicity to work with the Parse Server Cloud Code. I hope you'll enjoy it.

Happy Cloud Coding!

Marian Ignev

Managing Director of CloudStrap & SashiDo. Passionate Software Engineer & Visionary. Make things happen! Love to communicate with bright creative minds!

Find answers to all your questions

Our Frequently Asked Questions section is here to help.







Latests news

How to make your Mobile Application GDPR Ready

At SashiDo we certainly care about our customers and we strive to be up-to-date on the horizon of the novelties coming up. We’re all working on GDPR these days and we want to help people understand what it is. What does GDPR mean? In February we announced that GDPR is coming and SashiDo.io is getting ready and now we will be more specific on how to make sure your mobile app is prepared for the upcoming changes in the European Union region.

Read More

SashiDo Acquires Octobas

SashiDo is pleased to announce its recent acquisition of all the assets of Octobas.com, a robust and scalable backend for mobile and web apps based on Parse Open Source. For the past 2 years our mission has been to become a leading Parse Server hosting provider in the mobile and web apps development world as well as to continue improving our service, launching new features and providing quality and security to our customers.

Read More