Skip to content

Commit a7123a2

Browse files
committed
support for Hono , closes #149
1 parent 30f246d commit a7123a2

27 files changed

+1216
-75
lines changed

dist/index.browser.mjs

Lines changed: 258 additions & 6 deletions
Large diffs are not rendered by default.

dist/index.mjs

Lines changed: 276 additions & 15 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 45 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
"peerDependencies": {
8787
"@electric-sql/pglite": "^0.3.0",
88-
"better-sqlite3": "^11.8.1",
88+
"better-sqlite3": "^11.8.1 || ^12.6.2",
8989
"msnodesqlv8": "^4.1.0 || ^5.0.0",
9090
"mysql2": "^2.2.5 || ^3.9.4",
9191
"oracledb": "^6.3.0",
@@ -124,17 +124,19 @@
124124
},
125125
"devDependencies": {
126126
"@electric-sql/pglite": "^0.3.0",
127+
"@hono/node-server": "^1.14.4",
127128
"@rollup/plugin-commonjs": "^28.0.2",
128129
"@rollup/plugin-json": "^6.1.0",
129130
"@rollup/plugin-node-resolve": "^13.0.0",
130131
"@typescript-eslint/eslint-plugin": "^6.x",
131132
"@typescript-eslint/parser": "^6.x",
132133
"@vitest/coverage-v8": "^3.2.4",
133-
"better-sqlite3": "^11.8.1",
134+
"better-sqlite3": "^12.6.2",
134135
"cors": "^2.8.5",
135136
"eslint": "^8.57.0",
136137
"eslint-plugin-jest": "^27.1.7",
137138
"express": "^4.18.2",
139+
"hono": "^4.8.2",
138140
"msnodesqlv8": "^4.1.0",
139141
"mysql2": "^3.9.4",
140142
"oracledb": "^6.3.0",

src/bunPg/newDatabase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ let newPool = require('./newPool');
77
let lock = require('../lock');
88
let executeSchema = require('../pg/schema');
99
let express = require('../hostExpress');
10+
let hono = require('../hostHono');
1011
let hostLocal = require('../hostLocal');
1112
let doQuery = require('../query');
1213
let releaseDbClient = require('../table/releaseDbClient');
@@ -17,7 +18,7 @@ function newDatabase(connectionString, poolOptions) {
1718
poolOptions = poolOptions || { min: 1 };
1819
var pool = newPool(connectionString, poolOptions);
1920

20-
let c = { poolFactory: pool, hostLocal, express };
21+
let c = { poolFactory: pool, hostLocal, express, hono };
2122

2223
c.transaction = function(options, fn) {
2324
if ((arguments.length === 1) && (typeof options === 'function')) {

src/bunSqlite/newDatabase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let commit = require('../table/commit');
55
let rollback = require('../table/rollback');
66
let newPool = require('./newPool');
77
let express = require('../hostExpress');
8+
let hono = require('../hostHono');
89
let hostLocal = require('../hostLocal');
910
let doQuery = require('../query');
1011
let doSqliteFunction = require('../sqliteFunction');
@@ -16,7 +17,7 @@ function newDatabase(connectionString, poolOptions) {
1617
poolOptions = poolOptions || { min: 1 };
1718
var pool = newPool(connectionString, poolOptions);
1819

19-
let c = {poolFactory: pool, hostLocal, express};
20+
let c = { poolFactory: pool, hostLocal, express, hono };
2021

2122
c.transaction = function(options, fn) {
2223
if ((arguments.length === 1) && (typeof options === 'function')) {

src/client/createProviders.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function createProviders(index) {
6565
});
6666

6767
dbMap.express = index.express;
68+
dbMap.hono = index.hono;
6869

6970
function createPool(providerName, ...args) {
7071
const provider = index[providerName];
@@ -138,4 +139,4 @@ function negotiateCachedPool(fn, providers) {
138139

139140

140141

141-
module.exports = createProviders;
142+
module.exports = createProviders;

src/client/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function rdbClient(options = {}) {
6666
client.http = onProvider.bind(null, 'http');//todo
6767
client.mysql = onProvider.bind(null, 'mysql');
6868
client.express = express;
69+
client.hono = hono;
6970
client.close = close;
7071

7172
function close() {
@@ -153,6 +154,14 @@ function rdbClient(options = {}) {
153154
throw new Error('Cannot host express clientside');
154155
}
155156

157+
function hono(arg) {
158+
if (providers.hono) {
159+
return providers.hono(client, { ...options, ...arg });
160+
}
161+
else
162+
throw new Error('Cannot host hono clientside');
163+
}
164+
156165

157166

158167
function _createPatch(original, modified, ...restArgs) {

src/d1/newDatabase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let commit = require('../table/commit');
55
let rollback = require('../table/rollback');
66
let newPool = require('./newPool');
77
let express = require('../hostExpress');
8+
let hono = require('../hostHono');
89
let hostLocal = require('../hostLocal');
910
let doQuery = require('../query');
1011
let releaseDbClient = require('../table/releaseDbClient');
@@ -15,7 +16,7 @@ function newDatabase(d1Database, poolOptions) {
1516
poolOptions = poolOptions || { min: 1 };
1617
var pool = newPool(d1Database, poolOptions);
1718

18-
let c = {poolFactory: pool, hostLocal, express};
19+
let c = { poolFactory: pool, hostLocal, express, hono };
1920

2021
c.transaction = function(options, fn) {
2122
if ((arguments.length === 1) && (typeof options === 'function')) {

0 commit comments

Comments
 (0)