import{readEnvVariable as r}from"../../utils/envs/read-env-variable.js";import{exit as o}from"../../utils/process/exit.js";import{logger as m}from"../../tools/notifiers/logger.js";let i=null;const e=r("WEB_SERVER_IDLE_TIMEOUT");function n(){if(e){if(isNaN(+e))throw new Error(`IDLE_TIMEOUT must be a number, got ${e}`);i&&clearTimeout(i),i=setTimeout(()=>{m.info("Server is idle, stopping..."),o(0)},+e)}}function f(){return async(u,t)=>{n(),await t()}}export{f as idleTimeoutMiddleware,n as startIdleTimeout};
