boxlang-express 0.1.19

Released .

  • Added resave/saveUninitialized options to boxExpressSession(), mirroring express-session's own options of the same name. By default this middleware writes to the store on every request, even one that never reads or touches req.session — free against the default in-memory store, a real cost against anything out-of-process. saveUninitialized: false skips both the store write and the Set-Cookie for a new session that was never modified; resave: false skips the store write (cookie still refreshed) for an existing session that wasn't modified. A session that is modified is always saved regardless of either option. Both default to true (the historical behavior), so this doesn't change anything for existing consumers unless they opt in. See Session.bx.
  • Added Response.onBeforeSend(callback) — registers a callback that runs once, synchronously, the instant before headers are actually flushed. Needed to implement saveUninitialized correctly: whether to send a session cookie can depend on what next() did to req.session, but by the time next() returns to a middleware's own frame, a terminal handler further down the chain has normally already called _end() and flushed the headers — too late to add one there. The same technique express-session uses via monkey-patching res.end, done explicitly here since BoxLang can't intercept it that way. See Response.bx.