I'm using express Js and I want to export the port on which the server is running for some testing purpose. But the port seems to be only available inside callback function of app.listen.Is there any way I can export the port?
let server = app.listen(3000, 'localhost', ()=>{
let port = server.address().port;
})
// accesss port here
module.export = port; // what I want