express icon indicating copy to clipboard operation
express copied to clipboard

Feature/app.close

Open yaniv-peretz opened this issue 1 year ago • 0 comments

Breif

Currently inorder to close an express app (server) the developer needs to capture the returning http.server from app.listen. This practice is not documented by express, and requires the developers figure it out by reading the underlying app.listen code.

Solution / Expected Result

I propose to make an explicit app.close funtion. Calling app.close should close all the running servers, or specify a single port to close. One useful example is when creating a mock server that opened and closed during a test.

Content

Adds functionality to close the server by app.close().

Tests

> [email protected] test-close
> mocha --require test/support/env --reporter spec --bail test/app.close.js



  app.close()
    ✔ Should close a single app instance
    ✔ Should close multiple app instances


  2 passing (22ms)

yaniv-peretz avatar Sep 14 '22 20:09 yaniv-peretz