Skip to content

Instantly share code, notes, and snippets.

@okovalov
Created December 11, 2012 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okovalov/4260235 to your computer and use it in GitHub Desktop.
Save okovalov/4260235 to your computer and use it in GitHub Desktop.
Here is my helper which is included in app.js and which is being called in mysql provider
var helpers = require('../components/helpers');
var app = express();
app.set('helpers', helpers);
exports.getConfig = function (configSubDirectory, configName) {
var pathToConfig = __dirname + '/../../config/' + configSubDirectory + '/' + configName + '.js';
if ( ! require('fs').existsSync(pathToConfig)) {
console.log(pathToConfig, ' is not found!');
return false;
}
return require(pathToConfig);
};
createMysqlConnection = function (app) {
var mysqlConfig = app.settings.helpers.getConfig('provider', 'mysql');
if ( ! mysqlConfig) {
return null;
}
return mysql.createConnection(mysqlConfig.mysqlParameters);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment