Skip to content

Instantly share code, notes, and snippets.

@ritikm
Created October 15, 2013 22:57
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ritikm/6999942 to your computer and use it in GitHub Desktop.
Save ritikm/6999942 to your computer and use it in GitHub Desktop.
Pure-JS method of importing settings into Meteor.js. This file is put in server/lib.
environment = process.env.NODE_ENV || "development";
var settings = {
development: {
public: {},
private: {}
},
staging: {
public: {},
private: {}
},
production: {
public: {},
private: {}
}
};
if (!process.env.METEOR_SETTINGS) {
console.log("=> No METEOR_SETTINGS passed in, using locally defined settings.");
if (environment === "production") {
Meteor.settings = settings.production;
} else if (environment === "staging") {
Meteor.settings = settings.staging;
} else {
Meteor.settings = settings.development;
}
// Push a subset of settings to the client.
if (Meteor.settings && Meteor.settings.public) {
__meteor_runtime_config__.PUBLIC_SETTINGS = Meteor.settings.public;
}
}
@austinrivas
Copy link

Brilliant, but how do you prevent publishing private settings in your git repo using this pattern? or do you just gitignore this file entirely?

@avadhbsd
Copy link

avadhbsd commented Nov 1, 2014

if you are a 'dev' at some point of time, you will have to consider buying a github account upgrade for private repos and as private repos its only visible to owner and the ones whom he shares with.

@reustle
Copy link

reustle commented Feb 25, 2015

Regardless of if the repo is private or public, you should never push things like private keys or passwords to other services. Assume everyone at GitHub can see them (they can).

You can create your production settings file locally, then scp it to your server initially, and add it to your .gitignore file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment