@heyhru/app-dms-server 0.1.4 → 0.1.6
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/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ async function createDmsDb(url) {
|
|
|
14
14
|
const { createPgAdapter } = await import("./pg.adapter-BNI42SHT.js");
|
|
15
15
|
_db = createPgAdapter(url);
|
|
16
16
|
} else {
|
|
17
|
-
const { createSqliteAdapter } = await import("./sqlite.adapter-
|
|
17
|
+
const { createSqliteAdapter } = await import("./sqlite.adapter-SCNLOKBD.js");
|
|
18
18
|
_db = createSqliteAdapter(url.replace("sqlite://", ""));
|
|
19
19
|
}
|
|
20
20
|
return _db;
|
|
@@ -2,19 +2,25 @@ import "./chunk-QGM4M3NI.js";
|
|
|
2
2
|
|
|
3
3
|
// src/db/sqlite.adapter.ts
|
|
4
4
|
import { createSqlite, getSqlite, closeSqlite } from "@heyhru/server-util-sqlite";
|
|
5
|
+
function sanitizeParams(params) {
|
|
6
|
+
return params.map((v) => {
|
|
7
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
8
|
+
return v;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
5
11
|
function createSqliteAdapter(path) {
|
|
6
12
|
createSqlite({ path });
|
|
7
13
|
return {
|
|
8
14
|
async query(sql, params = []) {
|
|
9
|
-
const bound = params;
|
|
15
|
+
const bound = sanitizeParams(params);
|
|
10
16
|
return getSqlite().prepare(sql).all(...bound);
|
|
11
17
|
},
|
|
12
18
|
async queryOne(sql, params = []) {
|
|
13
|
-
const bound = params;
|
|
19
|
+
const bound = sanitizeParams(params);
|
|
14
20
|
return getSqlite().prepare(sql).get(...bound);
|
|
15
21
|
},
|
|
16
22
|
async run(sql, params = []) {
|
|
17
|
-
const bound = params;
|
|
23
|
+
const bound = sanitizeParams(params);
|
|
18
24
|
const result = getSqlite().prepare(sql).run(...bound);
|
|
19
25
|
return { changes: result.changes };
|
|
20
26
|
},
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.6",
|
|
7
7
|
"description": "DMS backend API server built on Fastify",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.mjs",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"typescript": "^6.0.2",
|
|
38
38
|
"vitest": "^4.1.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "d827df7dd09e2531cff8d57221c661af32880cef"
|
|
41
41
|
}
|