title: Where do I store read-only CONSTANT values I need to reference on the client and server in my Meteor application?
body: <p>There's several questions and posts about this but I still haven't found a good answer.  I have a Meteor application where I want to store one big giant configuration file of <code>CONSTANTS</code> that will be used throughout my application on the server and client, like this:</p>
  
  <pre><code>//  Constant values used throughout app
  DEFAULT_PLAYERS_PER_GAME = 4;
  DEFAULT_LENGTH_OF_GAME = 300000;
  DEFAULT_PLAYER_ACCOUNT_TYPE = 'basic';
  
  BASIC_MONTHLY_FEE = 0;
  PREMIUM_MONTHLY_FEE = 2.99;
  
  //  etc.etc.
  </code></pre>
  
  <p>So ideally I want all these values to be in <strong>one place in one file</strong> and I also need to reference them on the client.  For example to display to a user the monthly fee in a sign-up template.  That fee would be sourced in one place in my config file.</p>
  
  <p>Each time I need to actually reference a CONSTANT for a server transaction in my app, I know that I will get the value from the server behind a Meteor Method to prevent the user from changing the value on the client.  I haven't found a place in my app structure that lets the client access these CONSTANTS without being able to change them.  </p>
  
  <p>If they're stored on the client only, then when the server accesses them they could be changed by the user simply using the JavaScript console.  If they're stored on the server only, then I can't access them from the client to show the values to the user.  I assume if they're stored in both a client/server folder they're still at the mercy of being changed by the user on the client.</p>
  
  <p>I have a couple ideas but I've found none of them are ideal:</p>
  
  <ol>
  <li><p>Store them on the server only and use Meteor methods to return their values to the client.  This is hacky because the only way I've found to get the value from the Meteor method on the client is to set a session variable in the Meteor method callback and this doesn't always work in time because the callback is asynchronous.</p></li>
  <li><p>Use Environment Variables.  This is good for secure values but these cannot be seen by the client.</p></li>
  <li><p>Have two seperate config files on the server and client and just make sure all the server transactions use the server config file so values can't be changed?  I don't like this because then you have to update values in two different files.</p></li>
  </ol>