@stacksjs/router 0.75.279 → 0.75.283

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.
Files changed (2) hide show
  1. package/dist/health.js +1 -1
  2. package/package.json +16 -16
package/dist/health.js CHANGED
@@ -1 +1 @@
1
- export async function runHealthProbes(probes,options={}){const timeoutMs=options.timeoutMs??1500,now=options.now??Date.now,entries=await Promise.all(probes.map(async({name,run})=>{const startedAt=now();let timeout;try{await Promise.race([run(),new Promise((_resolve,reject)=>{timeout=setTimeout(()=>reject(Error("timeout")),timeoutMs)})]);return[name,{ok:!0,ms:Math.max(0,now()-startedAt)}]}catch(error){return[name,{ok:!1,ms:Math.max(0,now()-startedAt),message:error instanceof Error?error.message:String(error)}]}finally{if(timeout)clearTimeout(timeout)}})),checks=Object.fromEntries(entries);return{status:Object.values(checks).every((check)=>check.ok)?"healthy":"degraded",checks,timestamp:now()}}const BROKEN_POOL_HEALTH_MESSAGE="Database pool broken by oven-sh/bun#42804 until the process restarts. The server log names the pool.";function throwIfDatabasePoolBroken(database){if(database.getBrokenDatabasePools().length>0)throw Error(BROKEN_POOL_HEALTH_MESSAGE)}export async function checkApplicationHealth(options={}){return runHealthProbes([{name:"database",async run(){const database=await import("@stacksjs/database/runtime");throwIfDatabasePoolBroken(database);const{db}=database,unsafe=db.unsafe;if(typeof unsafe!=="function")throw Error("database driver does not expose a raw health probe");try{await unsafe.call(db,"SELECT 1")}catch(error){database.recordPrimaryDatabaseQueryError(error);throwIfDatabasePoolBroken(database);throw error}}},{name:"cache",async run(){const{cache}=await import("@stacksjs/cache"),key=`__health__:${Date.now()}`;let stored=!1;try{await cache.set(key,1,5);stored=!0}finally{if(stored)await cache.del(key)}}}],options)}
1
+ export async function runHealthProbes(probes,options={}){const timeoutMs=options.timeoutMs??1500,now=options.now??Date.now,entries=await Promise.all(probes.map(async({name,run})=>{const startedAt=now();let timeout;try{await Promise.race([run(),new Promise((_resolve,reject)=>{timeout=setTimeout(()=>reject(Error("timeout")),timeoutMs)})]);return[name,{ok:!0,ms:Math.max(0,now()-startedAt)}]}catch(error){return[name,{ok:!1,ms:Math.max(0,now()-startedAt),message:error instanceof Error?error.message:String(error)}]}finally{if(timeout)clearTimeout(timeout)}})),checks=Object.fromEntries(entries);return{status:Object.values(checks).every((check)=>check.ok)?"healthy":"degraded",checks,timestamp:now()}}export async function checkApplicationHealth(options={}){return runHealthProbes([{name:"database",async run(){const{db}=await import("@stacksjs/database/runtime"),unsafe=db.unsafe;if(typeof unsafe!=="function")throw Error("database driver does not expose a raw health probe");await unsafe.call(db,"SELECT 1")}},{name:"cache",async run(){const{cache}=await import("@stacksjs/cache"),key=`__health__:${Date.now()}`;let stored=!1;try{await cache.set(key,1,5);stored=!0}finally{if(stored)await cache.del(key)}}}],options)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/router",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.279",
5
+ "version": "0.75.283",
6
6
  "description": "The Stacks framework router.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -67,27 +67,27 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@stacksjs/bun-router": "^0.1.24",
70
- "@stacksjs/cache": "0.75.279",
71
- "@stacksjs/collections": "0.75.279",
72
- "@stacksjs/config": "0.75.279",
73
- "@stacksjs/error-handling": "0.75.279",
74
- "@stacksjs/logging": "0.75.279",
75
- "@stacksjs/pagination": "0.75.279",
76
- "@stacksjs/path": "0.75.279",
77
- "@stacksjs/security": "0.75.279",
78
- "@stacksjs/storage": "0.75.279",
70
+ "@stacksjs/cache": "0.75.283",
71
+ "@stacksjs/collections": "0.75.283",
72
+ "@stacksjs/config": "0.75.283",
73
+ "@stacksjs/error-handling": "0.75.283",
74
+ "@stacksjs/logging": "0.75.283",
75
+ "@stacksjs/pagination": "0.75.283",
76
+ "@stacksjs/path": "0.75.283",
77
+ "@stacksjs/security": "0.75.283",
78
+ "@stacksjs/storage": "0.75.283",
79
79
  "ts-rate-limiter": "^0.4.10"
80
80
  },
81
81
  "devDependencies": {
82
- "@stacksjs/actions": "0.75.279",
83
- "@stacksjs/types": "0.75.279",
82
+ "@stacksjs/actions": "0.75.283",
83
+ "@stacksjs/types": "0.75.283",
84
84
  "better-dx": "^0.2.24"
85
85
  },
86
86
  "peerDependencies": {
87
- "@stacksjs/api": "0.75.279",
88
- "@stacksjs/auth": "0.75.279",
89
- "@stacksjs/database": "0.75.279",
90
- "@stacksjs/validation": "0.75.279"
87
+ "@stacksjs/api": "0.75.283",
88
+ "@stacksjs/auth": "0.75.283",
89
+ "@stacksjs/database": "0.75.283",
90
+ "@stacksjs/validation": "0.75.283"
91
91
  },
92
92
  "peerDependenciesMeta": {
93
93
  "@stacksjs/api": {