db-bridge 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Berke Erdoğan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # DB Bridge
2
+
3
+ Unified database adapter for Node.js with MySQL, PostgreSQL, and Redis support.
4
+
5
+ ## Installation
6
+
7
+ ### Install everything (recommended for new projects):
8
+
9
+ ```bash
10
+ npm install db-bridge
11
+ ```
12
+
13
+ ### Or install only what you need:
14
+
15
+ ```bash
16
+ # Core + MySQL only
17
+ npm install @db-bridge/core @db-bridge/mysql
18
+
19
+ # Core + Redis only
20
+ npm install @db-bridge/core @db-bridge/redis
21
+
22
+ # Core + PostgreSQL only
23
+ npm install @db-bridge/core @db-bridge/postgresql
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```javascript
29
+ import { DBBridge } from 'db-bridge';
30
+ // or
31
+ const { DBBridge } = require('db-bridge');
32
+
33
+ // MySQL
34
+ const mysql = DBBridge.mysql({
35
+ host: 'localhost',
36
+ user: 'root',
37
+ password: 'password',
38
+ database: 'mydb',
39
+ });
40
+
41
+ // PostgreSQL
42
+ const pg = DBBridge.postgresql({
43
+ host: 'localhost',
44
+ user: 'postgres',
45
+ password: 'password',
46
+ database: 'mydb',
47
+ });
48
+
49
+ // Redis
50
+ const redis = DBBridge.redis({
51
+ host: 'localhost',
52
+ port: 6379,
53
+ });
54
+
55
+ // Connect and use
56
+ await mysql.connect();
57
+ const users = await mysql.query('SELECT * FROM users');
58
+ await mysql.disconnect();
59
+ ```
60
+
61
+ ## Why DB Bridge?
62
+
63
+ - πŸš€ **Unified API** - Same interface for all databases
64
+ - πŸ“¦ **Optional Dependencies** - Install only what you need
65
+ - πŸ”„ **Auto Driver Installation** - Database drivers are included
66
+ - πŸ’ͺ **TypeScript Support** - Full type safety
67
+ - 🏊 **Connection Pooling** - Built-in pool management
68
+ - πŸ”’ **Transactions** - ACID compliance
69
+ - πŸ” **Query Builder** - Type-safe query construction
70
+ - ⚑ **Redis Integration** - Built-in caching support
71
+
72
+ ## Features
73
+
74
+ ### Consistent API
75
+
76
+ ```javascript
77
+ // Same methods work across all databases
78
+ await db.connect();
79
+ await db.query('SELECT * FROM users');
80
+ await db.execute('INSERT INTO users VALUES (?, ?)', ['John', 'john@example.com']);
81
+ await db.disconnect();
82
+ ```
83
+
84
+ ### Query Builder
85
+
86
+ ```javascript
87
+ const users = await db
88
+ .createQueryBuilder()
89
+ .table('users') // or .from('users')
90
+ .select('id', 'name', 'email')
91
+ .where('active', '=', true)
92
+ .orderBy('created_at', 'DESC')
93
+ .limit(10)
94
+ .execute();
95
+ ```
96
+
97
+ ### Transactions
98
+
99
+ ```javascript
100
+ const trx = await db.beginTransaction();
101
+ try {
102
+ await trx.execute('UPDATE accounts SET balance = balance - ? WHERE id = ?', [100, 1]);
103
+ await trx.execute('UPDATE accounts SET balance = balance + ? WHERE id = ?', [100, 2]);
104
+ await trx.commit();
105
+ } catch (error) {
106
+ await trx.rollback();
107
+ }
108
+ ```
109
+
110
+ ### Redis Caching
111
+
112
+ ```javascript
113
+ const cache = DBBridge.redis();
114
+ await cache.connect();
115
+
116
+ // Basic operations
117
+ await cache.set('key', { data: 'value' }, 3600); // 1 hour TTL
118
+ const data = await cache.get('key');
119
+ await cache.del('key');
120
+
121
+ // Redis commands
122
+ const redis = cache.getAdapter();
123
+ await redis.commands.lpush('queue', 'task1', 'task2');
124
+ await redis.commands.hset('user:1', 'name', 'John');
125
+ ```
126
+
127
+ ## License
128
+
129
+ MIT
@@ -0,0 +1,5 @@
1
+ export * from '@db-bridge/core';
2
+ export { DBBridge, DBBridge as default } from '@db-bridge/core';
3
+ export { MySQLAdapter, MySQLAdapterOptions } from '@db-bridge/mysql';
4
+ export { PostgreSQLAdapter, PostgreSQLAdapterOptions } from '@db-bridge/postgresql';
5
+ export { RedisAdapter, RedisAdapterOptions } from '@db-bridge/redis';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // src/index.ts
2
+ export * from "@db-bridge/core";
3
+ import { DBBridge, DBBridge as DBBridge2 } from "@db-bridge/core";
4
+ import { MySQLAdapter } from "@db-bridge/mysql";
5
+ import { PostgreSQLAdapter } from "@db-bridge/postgresql";
6
+ import { RedisAdapter } from "@db-bridge/redis";
7
+ export {
8
+ DBBridge,
9
+ MySQLAdapter,
10
+ PostgreSQLAdapter,
11
+ RedisAdapter,
12
+ DBBridge2 as default
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * DB Bridge - All-in-one package\n *\n * This package includes all database adapters for convenience.\n * Users can install this single package to get everything:\n *\n * ```bash\n * npm install db-bridge\n * ```\n *\n * Or install individual packages for smaller bundle size:\n *\n * ```bash\n * npm install @db-bridge/core @db-bridge/mysql\n * npm install @db-bridge/core @db-bridge/redis\n * npm install @db-bridge/core @db-bridge/postgresql\n * ```\n */\n\n// Re-export everything from core\n// Convenience default export\n\nexport * from '@db-bridge/core';\nexport { DBBridge, DBBridge as default } from '@db-bridge/core';\n\n// Re-export all adapters\nexport { MySQLAdapter } from '@db-bridge/mysql';\nexport type { MySQLAdapterOptions } from '@db-bridge/mysql';\n\nexport { PostgreSQLAdapter } from '@db-bridge/postgresql';\nexport type { PostgreSQLAdapterOptions } from '@db-bridge/postgresql';\n\nexport { RedisAdapter } from '@db-bridge/redis';\nexport type { RedisAdapterOptions } from '@db-bridge/redis';\n"],"mappings":";AAsBA,cAAc;AACd,SAAS,UAAsB,YAAZA,iBAA2B;AAG9C,SAAS,oBAAoB;AAG7B,SAAS,yBAAyB;AAGlC,SAAS,oBAAoB;","names":["DBBridge"]}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "db-bridge",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Unified database adapter for Node.js - All-in-one package with MySQL, PostgreSQL, and Redis support",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsup",
15
+ "dev": "tsup --watch",
16
+ "clean": "rimraf dist",
17
+ "typecheck": "tsc --noEmit",
18
+ "prepublishOnly": "npm run clean && npm run build"
19
+ },
20
+ "dependencies": {
21
+ "@db-bridge/core": "^1.0.0",
22
+ "@db-bridge/mysql": "^1.0.0",
23
+ "@db-bridge/postgresql": "^1.0.0",
24
+ "@db-bridge/redis": "^1.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^20.10.5",
28
+ "rimraf": "^5.0.5",
29
+ "tsup": "^8.0.1",
30
+ "typescript": "^5.3.3"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "keywords": [
38
+ "database",
39
+ "mysql",
40
+ "postgresql",
41
+ "postgres",
42
+ "redis",
43
+ "adapter",
44
+ "orm",
45
+ "query-builder",
46
+ "cache",
47
+ "typescript",
48
+ "nodejs",
49
+ "sql",
50
+ "nosql",
51
+ "unified",
52
+ "driver",
53
+ "connection-pool",
54
+ "transactions"
55
+ ],
56
+ "author": "Berke Erdogan",
57
+ "license": "MIT",
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/berkeerdogan/db-bridge.git"
61
+ },
62
+ "homepage": "https://github.com/berkeerdogan/db-bridge#readme",
63
+ "engines": {
64
+ "node": ">=16.0.0"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "gitHead": "7aaca822d0d43120f453562de592e48e7d3e8d32"
70
+ }