easy-database-connector
Advanced tools
Comparing version 1.0.6 to 1.0.7
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mssql = exports.redisService = exports.queryWithPagination = exports.transaction = exports.execute = exports.query = void 0; | ||
var database_1 = require("./core/database"); | ||
Object.defineProperty(exports, "query", { enumerable: true, get: function () { return database_1.query; } }); | ||
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return database_1.execute; } }); | ||
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return database_1.transaction; } }); | ||
Object.defineProperty(exports, "queryWithPagination", { enumerable: true, get: function () { return database_1.queryWithPagination; } }); | ||
var redis_service_1 = require("./services/redis.service"); | ||
Object.defineProperty(exports, "redisService", { enumerable: true, get: function () { return redis_service_1.redisService; } }); | ||
var database_types_1 = require("./types/database.types"); | ||
Object.defineProperty(exports, "mssql", { enumerable: true, get: function () { return database_types_1.mssql; } }); | ||
const example = async () => { | ||
// const data = await query({ | ||
// sql: "select top 10 * from users", | ||
// parameters:[] | ||
// }) | ||
const data = "deneme"; | ||
console.log(data); | ||
}; | ||
example(); |
@@ -7,17 +7,42 @@ "use strict"; | ||
let client = null; | ||
const initializeClient = () => { | ||
if (database_config_1.redisConfig.enabled && !client) { | ||
let connectionAttempts = 0; | ||
const MAX_RETRIES = 5; | ||
const RETRY_DELAY = 5000; | ||
const initializeClient = async () => { | ||
if (!database_config_1.redisConfig.enabled || client) | ||
return; | ||
try { | ||
client = (0, redis_1.createClient)({ | ||
socket: { | ||
host: database_config_1.redisConfig.host, | ||
port: database_config_1.redisConfig.port | ||
port: database_config_1.redisConfig.port, | ||
connectTimeout: 10000, | ||
reconnectStrategy: (retries) => { | ||
if (retries > MAX_RETRIES) { | ||
console.error(`Failed to connect to Redis after ${MAX_RETRIES} attempts`); | ||
return new Error('Max retries reached'); | ||
} | ||
return RETRY_DELAY; | ||
} | ||
}, | ||
password: database_config_1.redisConfig.password | ||
}); | ||
client.connect().catch(err => { | ||
console.error('Error connecting to Redis:', err); | ||
client.on('error', (err) => { | ||
console.error('Redis Client Error:', err); | ||
}); | ||
client.on('connect', () => { | ||
console.log('Successfully connected to Redis'); | ||
connectionAttempts = 0; | ||
}); | ||
await client.connect(); | ||
} | ||
catch (err) { | ||
connectionAttempts++; | ||
console.error(`Redis connection attempt ${connectionAttempts} failed:`, err); | ||
if (connectionAttempts < MAX_RETRIES) { | ||
console.log(`Retrying connection in ${RETRY_DELAY / 1000} seconds...`); | ||
setTimeout(initializeClient, RETRY_DELAY); | ||
} | ||
} | ||
}; | ||
initializeClient(); | ||
exports.redisService = { | ||
@@ -24,0 +49,0 @@ get: async (key) => { |
{ | ||
"name": "easy-database-connector", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A flexible database connector service with MSSQL support, pagination, caching, and encryption", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20697
373