Skip to content

Instantly share code, notes, and snippets.

@bkonkle
Created November 6, 2013 03:58
Show Gist options
  • Save bkonkle/7330667 to your computer and use it in GitHub Desktop.
Save bkonkle/7330667 to your computer and use it in GitHub Desktop.
Handing off config variables to the frontend
define(function (require) {
'use strict';
var Cookies = require('cookies-js');
var configJson = Cookies.get('config');
if (configJson.slice(0, 2) === 'j:') {
return JSON.parse(configJson.slice(2));
}
});
var dotenv = require('dotenv');
dotenv.load();
var config = {
'debug': process.env.DEBUG,
'logRoutes': process.env.LOGROUTES
};
module.exports = config;
/*
* GET home page.
*/
'use strict';
var config = require('../config');
exports.index = function (req, res) {
res.cookie('config', config);
res.render('index', {
title: 'In Character'
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment