52
loading...
This website collects cookies to deliver better user experience
node_modules
by 11 KB to get tranquility that your node.js HTTP server is shutting down without data loss risk.npm i lil-http-terminator
connection: close
headerimport { createHttpTerminator } from 'http-terminator';
const httpTerminator = createHttpTerminator({ server });
await httpTerminator.terminate();
node_modules
.$ npx howfat -r tree http-terminator
npx: installed 18 in 1.695s
[email protected] (22 deps, 2.16mb, 464 files)
├── [email protected] (10.91kb, 5 files)
├─┬ [email protected] (19 deps, 2.02mb, 398 files)
│ ├── [email protected] (7.9kb, 10 files)
│ ├── [email protected] (2.7kb, 6 files)
│ ├─┬ [email protected] (9 deps, 1.79mb, 268 files)
│ │ ├─┬ [email protected] (5 deps, 1.41mb, 181 files)
│ │ │ ├── [email protected] (12.66kb, 11 files)
│ │ │ ├── [email protected] (16.56kb, 18 files)
│ │ │ ├── [email protected] (19.11kb, 9 files)
│ │ │ ╰─┬ [email protected] (1 dep, 490.54kb, 51 files)
│ │ │ ╰── [email protected] (31.67kb, 5 files)
│ │ ├── [email protected] (29.39kb, 9 files)
│ │ ├── [email protected] (23.48kb, 9 files)
│ │ ╰── [email protected] (10.73kb, 5 files)
│ ├─┬ [email protected] (1 dep, 34.32kb, 26 files)
│ │ ╰── [email protected] (🔗, 7.9kb, 10 files)
│ ├─┬ [email protected] (2 deps, 114.41kb, 41 files)
│ │ ╰─┬ [email protected] (1 dep, 48.41kb, 21 files)
│ │ ╰── [email protected] (25.92kb, 11 files)
│ ├── [email protected] (5.89kb, 8 files)
│ ├── [email protected] (12.42kb, 9 files)
│ ╰── [email protected] (3.96kb, 8 files)
╰── [email protected] (108kb, 42 files)
roarr
package and if it can be removed from the package? The answer got me by surprise.type-fest
can be removed by rewriting the package from TS to JS. Hold saying your "boo" yet.delay
module can be rewritten as a single-line function. Here it is:const delay = time => new Promise(r => setTimeout(r, time));
roarr
module, the largest of the tree, takes 2 MB of your hard drive. But it is used literally in the single line!!!if (terminating) {
log.warn('already terminating HTTP server');
return terminating;
}
roarr
logger within the whole http-terminator
module..termiate()
twice. It's hard to imagine this ever happens. So I decided to put the log
variable to options
and assign it to console
by default.winston
, bunyan
, pino
, morgan
, etc; or even the roarr
itself).const HttpTerminator = require("lil-http-terminator");
const httpTerminator = HttpTerminator({ server });
await httpTerminator.terminate();
lil-
version is:lil-http-terminator
in two hours. I foresee saving myself from 8 to 80 hours this way. You can save the same.