deprecating use of templates.setGlobal on server side in favour of passing in api.config into res.locals (still needs work)

This commit is contained in:
psychobunny
2014-03-03 12:16:46 -05:00
parent 188aeabba8
commit 5b8e8e4b67
2 changed files with 28 additions and 12 deletions

View File

@@ -7,9 +7,8 @@ var pkg = require('./../../package.json'),
var apiController = {};
apiController.getConfig = function(req, res, next, callback) {
var config = require('../../public/config.json');
apiController.getConfig = function(req, res, next) {
var config = require('./../../public/config.json');
config.version = pkg.version;
config.postDelay = meta.config.postDelay;
@@ -35,23 +34,23 @@ apiController.getConfig = function(req, res, next, callback) {
config.environment = process.env.NODE_ENV;
if (!req.user) {
return res.json(200, config);
if (res.locals.isAPI) {
res.json(200, config);
} else {
next(null, config);
}
}
if(req.user) {
user.getSettings(req.user.uid, function(err, settings) {
if(err) {
return next(err);
}
config.usePagination = settings.usePagination;
config.topicsPerPage = settings.topicsPerPage;
config.postsPerPage = settings.postsPerPage;
if (callback) {
callback(err, config);
} else {
if (res.locals.isAPI) {
res.json(200, config);
} else {
next(err, config);
}
});
}