@healthzkit/mongo 0.0.3 → 0.0.4
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/mongodb.d.mts +1 -1
- package/dist/mongodb.mjs +1 -1
- package/dist/mongoose.d.mts +1 -1
- package/dist/mongoose.mjs +1 -1
- package/dist/shared-BiUsKU63.mjs +1 -0
- package/dist/shared-D2N9p6gZ.d.mts +12 -0
- package/package.json +4 -2
- package/dist/dist-iC8gGE1z.mjs +0 -1
- package/dist/shared-CkMHx8WJ.d.mts +0 -16
package/dist/mongodb.d.mts
CHANGED
package/dist/mongodb.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./
|
|
1
|
+
import{n as e,t}from"./shared-BiUsKU63.mjs";function n(n){let r=null,i=null,a=null;async function o(e,t){return i??=(async()=>{let{MongoClient:n}=await import(`mongodb`),i=new n(e,t);return await i.connect(),r=i,i})().catch(e=>{throw i=null,r=null,e}),i}async function s(){if(`connectionString`in n&&n.connectionString)return o(n.connectionString,n.mongoOptions);if(`client`in n&&n.client)return a??=n.client.connect().then(()=>void 0).catch(e=>{throw a=null,e}),await a,n.client;throw Error(`mongoAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let t=await s(),r=Date.now();await t.db(`admin`).command({ping:1});let i=Date.now()-r,a=n.metadata?n.metadata(t):void 0;return e(i,a instanceof Promise?await a:a)}catch(e){return t(e)}},async close(){r&&(await r.close(),r=null,i=null)}}}export{n as mongodbAdapter};
|
package/dist/mongoose.d.mts
CHANGED
package/dist/mongoose.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./
|
|
1
|
+
import{n as e,t}from"./shared-BiUsKU63.mjs";function n(n){let r=null;async function i(e,t){return r??=(async()=>{let{default:n}=await import(`mongoose`);return await n.connect(e,t),n})().catch(e=>{throw r=null,e}),r}async function a(){if(`connectionString`in n&&n.connectionString)return i(n.connectionString,n.mongooseOptions);let e=n.connection;if(!e)throw Error(`mongoose adapter requires connection or connectionString`);return`readyState`in e&&e.readyState!==1&&await e.asPromise(),e}return{async check(){try{let t=await a(),r=Date.now(),i=`db`in t?t.db:t.connection.db;if(!i)throw Error(`mongoose adapter: database unavailable`);await i.admin().command({ping:1});let o=Date.now()-r,s=n.metadata?n.metadata(t):void 0;return e(o,s instanceof Promise?await s:s)}catch(e){return t(e)}}}}export{n as mongooseAdapter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildErrorResult as e,buildResult as t}from"@healthzkit/shared";export{t as n,e as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HealthAdapter, MetadataFn } from "@healthzkit/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/shared.d.ts
|
|
4
|
+
interface BaseMongoOptions<TClient> {
|
|
5
|
+
/**
|
|
6
|
+
* Optional function to populate metadata in the check result.
|
|
7
|
+
* Receives the resolved client so you can run additional queries.
|
|
8
|
+
*/
|
|
9
|
+
metadata?: MetadataFn<TClient>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { HealthAdapter as n, BaseMongoOptions as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healthzkit/mongo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@healthzkit/shared": "0.0.0"
|
|
25
|
+
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"@types/mongodb": "^4.0.7",
|
|
25
28
|
"@types/mongoose": "^5.11.97",
|
|
@@ -30,7 +33,6 @@
|
|
|
30
33
|
"mongoose": "^9.6.2",
|
|
31
34
|
"typescript": "^5",
|
|
32
35
|
"vite-plus": "latest",
|
|
33
|
-
"@healthzkit/shared": "0.0.0",
|
|
34
36
|
"healthzkit": "0.0.3"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|
package/dist/dist-iC8gGE1z.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){return{status:`ok`,metadata:{...t,latencyMs:e}}}function t(e){return{status:`fail`,error:e instanceof Error?e:Error(String(e))}}export{t as n,e as t};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { HealthAdapter } from "healthzkit";
|
|
2
|
-
|
|
3
|
-
//#region ../../tools/shared/dist/index.d.mts
|
|
4
|
-
//#region src/index.d.ts
|
|
5
|
-
type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/shared.d.ts
|
|
8
|
-
interface BaseMongoOptions<TClient> {
|
|
9
|
-
/**
|
|
10
|
-
* Optional function to populate metadata in the check result.
|
|
11
|
-
* Receives the resolved client so you can run additional queries.
|
|
12
|
-
*/
|
|
13
|
-
metadata?: MetadataFn<TClient>;
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { HealthAdapter as n, BaseMongoOptions as t };
|