Created
November 6, 2013 03:58
-
-
Save bkonkle/7330667 to your computer and use it in GitHub Desktop.
Handing off config variables to the frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dotenv = require('dotenv'); | |
dotenv.load(); | |
var config = { | |
'debug': process.env.DEBUG, | |
'logRoutes': process.env.LOGROUTES | |
}; | |
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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