Friday 11 March 2016

"global" objects and variable

Hey guys,following two questions:How can I share a variable between e.g. routes? I need to access it in a route path and a middlewareIs require "global? Having the following file:*var mysql = require('mysql'); var pool = mysql.createPool({ connectionLimit : 100, host : 'localhost', user : 'root', password : 'password', database : 'database', }); module.exports = pool; When using var db = require('../db') in multiple route paths, is it a single global pool or is a new pool initiate for every route? If it isn't a single one, how can I achieve this behavior?

Submitted March 11, 2016 at 01:19PM by ArghusSquare

No comments:

Post a Comment