Created
December 11, 2012 16:53
-
-
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
This file contains hidden or 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 helpers = require('../components/helpers'); | |
var app = express(); | |
app.set('helpers', helpers); |
This file contains hidden or 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
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); | |
}; |
This file contains hidden or 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
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