Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const config1 = {
- user: 'web',
- password: '19461946',
- server: '192.168.44.110', // You can use 'localhost\\instance' to connect to named instance
- database: 'Testing20172018',
- port: '1433',
- options: {
- trustedConnection: true
- }
- }
- const config = {
- user: 'usuario_node',
- password: 'node123',
- server: 'localhost', // You can use 'localhost\\instance' to connect to named instance
- database: 'pruebas_node',
- port: '1433',
- options: {
- trustedConnection: true
- }
- }
- config.parseJSON =true
- var sql = require('mssql')
- const secret= 'Ccross2in0ven0ta1ri7o'
- const saltRounds = 10;
- function getConnectionPoolGlobal(config){
- function conect(resolve,reject){
- if (global.poolGlobal){
- console.log('Reutilizando pool '+poolGlobal.listenerCount())
- resolve(poolGlobal)
- }
- else{
- new sql.ConnectionPool(config).connect().then(poolObt=>{
- global.poolGlobal=poolObt
- resolve(global.poolGlobal)
- console.log('Nuevo pool Creado')
- }).catch(err =>{
- reject(err)
- })
- }
- }
- return new Promise(conect)
- }
- function getConnectionPool(config,sql){
- function getpool(resolve,reject){
- new sql.ConnectionPool(config).connect().then(pool=>{
- resolve(pool)
- }).catch(err =>{
- reject(err)
- })
- }
- return new Promise(getpool)
- }
- module.exports={
- "config":config,
- "getConnectionPool":getConnectionPool,
- "getConnectionPoolGlobal":getConnectionPoolGlobal,
- "saltRounds":saltRounds,
- "secret":secret
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement