vantage icon indicating copy to clipboard operation
vantage copied to clipboard

Allow banner to be a function so banner can change depending on app state, or environment state

Open zakhenry opened this issue 9 years ago • 0 comments

Currently, the banner is assigned on boot:

var banner = 
"######################################################################" + 
"#                    Welcome to joescrabshack.com                    #" + 
"#                                                                    #" +
"#              All connections are monitored and recorded            #" + 
"#      Disconnect IMMEDIATELY if you are not an authorized user      #" + 
"######################################################################";
vantage
  .delimiter('appsvr:3000~$')
  .banner(banner)
  .listen(3000);

However this means that the context can only be when the banner was registered.

Instead, if the api could accept a banner, ie

vantage
  .delimiter('appsvr:3000~$')
  .banner(() => {
    if (process.stdout.columns < 70){
      return;
    }
    return banner;
  })
  .listen(3000);

Then the banner could be changed depending on the app state, or environment state. Some benefiting examples

  • process.stdout.columns could be inspected to hide/resize wide banners (this currently only works if the same size shell as what booted the app in the first place is used)
  • status of the running application could be returned, maybe a list of the last X exceptions
  • Notifications that migrations need to be run etc

zakhenry avatar Jun 05 '16 17:06 zakhenry