Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
database-connector-service
Advanced tools
A TypeScript-based service for managing MySQL, MSSQL, and Redis connections.
Esnek ve güçlü bir Node.js veritabanı bağlayıcısı. MySQL ve MSSQL için yerleşik destek, Redis önbellekleme, sorgu oluşturma ve işlem yönetimi özellikleri sunar.
npm install database-connector-service
Proje kök dizininizde bir .env
dosyası oluşturun:
# Veritabanı Yapılandırması
DB_TYPE=mysql # veya mssql
DB_HOST=localhost
DB_USER=your_username
DB_PASSWORD=your_password
DB_DATABASE=your_database
DB_PORT=3306 # MySQL=3306, MSSQL=1433
DB_ENCRYPT=false # MSSQL için
# Redis Yapılandırması (İsteğe bağlı)
REDIS_ENABLED=true
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_TTL=3600
import { createQueryBuilder, query, execute, transaction } from 'database-connector-service';
// 1. Basit Sorgu
const users = await query(
'SELECT * FROM users WHERE active = ?',
[true]
);
// 2. Önbellekli
const cachedUsers = await query(
'SELECT * FROM users WHERE active = ?',
[true],
{
cache: {
key: 'active-users',
ttl: 3600
}
}
);
// 3. Sayfalama
const { data, pagination } = await queryWithPagination(
'SELECT * FROM users WHERE active = ?',
[true],
{
page: 1,
pageSize: 10,
orderBy: 'name',
direction: 'ASC'
}
);
// İşlem örneği
await transaction(async (trx) => {
await trx.query('INSERT INTO users (name) VALUES (?)', ['John']);
await trx.query('UPDATE stats SET total = total + 1');
});
const users = createQueryBuilder('users');
// SELECT örneği
const activeUsers = await users
.select()
.select('id', 'name', 'email')
.where('status', '=', 'active')
.leftJoin('orders', 'users.id = orders.user_id')
.groupBy('role')
.having('COUNT(*) > 5')
.orderBy('created_at', 'DESC')
.cache('active-users', 3600)
.execute<User>();
// INSERT örneği
await users
.insert()
.values({
name: 'John',
email: 'john@example.com'
})
.invalidateCache('users', 'stats')
.execute();
// UPDATE örneği
await users
.update()
.set({
status: 'inactive',
updated_at: new Date()
})
.where('id', '=', 1)
.invalidateCache('users')
.execute();
// DELETE örneği
await users
.delete()
.where('status', '=', 'inactive')
.invalidateCache('users', 'stats')
.execute();
// Transaction örneği
await users.transaction(async (trx) => {
await users
.insert()
.values({ name: 'John' })
.execute();
await users
.update()
.set({ total: 100 })
.where('type', '=', 'user')
.execute();
});
// Pagination örneği
const { data, pagination } = await users
.select()
.where('active', '=', true)
.orderBy('name')
.paginate<User>({ page: 1, pageSize: 20 });
// 1. Sorgu Oluşturucu ile Önbellekleme
const users = createQueryBuilder('users');
const users = await createQueryBuilder('users')
.select()
.where('status', '=', 'active')
.cache('active-users', 3600)
.execute<User>();
// 2. Çoklu Önbellek Desenlerini İnvalidasyon
await invalidateCache(['users', 'orders', 'stats']);
// 3. Otomatik Önbellek İnvalidasyonu
await execute(
'INSERT INTO users (name) VALUES (?)',
['John'],
['users', 'user_stats'] // invalidasyon için önbellek desenleri
);
// İşlem Örneği
await transaction(async (trx) => {
// Kullanıcı ekle
const [user] = await trx.query(
'INSERT INTO users (name) VALUES (?) RETURNING id',
['John']
);
// Kullanıcı ID'sini kullanarak profil ekle
await trx.query(
'INSERT INTO profiles (user_id, bio) VALUES (?, ?)',
[user.id, 'New user bio']
);
// İstatistikleri güncelle
await trx.query(
'UPDATE user_stats SET total = total + 1'
);
});
Katkılarınızı bekliyoruz! Lütfen Pull Request göndermekten çekinmeyin.
MIT
FAQs
A TypeScript-based service for managing MySQL, MSSQL, and Redis connections.
The npm package database-connector-service receives a total of 1 weekly downloads. As such, database-connector-service popularity was classified as not popular.
We found that database-connector-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.