boxlang-express 0.1.14
Released .
- Fix + feature:
app.get(path, ...)routes now automatically answerHEADtoo — same handler and headers (includingContent-Length), body discarded, same as Express — instead of 404ing. This also fixes a real bug in static file serving: it already acceptedHEADrequests, but sent the full file body anyway, a spec violation for aHEADresponse. Registerapp.head(path, ...)explicitly (before the matchingapp.get()) only whenHEADshould behave differently than discarding theGETbody. - Fix:
app.use()/router.use()only ever accepted a single handler (or a single path + single handler), unlike route registration (app.get(path, mw1, mw2, handler)), which already took a variadic chain. Callingapp.use(mw1, mw2, mw3)— a common Express pattern — didn't just silently drop the extra arguments, it threw a confusing low-level error (the second handler got mistaken for a mount path).use()now accepts any number of handlers (and/or aRouter) in one call, at the same mount point, registered in order. See Router.bx. - Added
boxExpressHelmet()— security-headers middleware mirroring the npmhelmetpackage's most commonly used defaults (X-Frame-Options,X-Content-Type-Options,Referrer-Policy, etc.), each individually overridable or disable-able.Strict-Transport-SecurityandContent-Security-Policyare opt-in rather than on by default. See Helmet.bx. - Added
boxExpressCors()— Cross-Origin Resource Sharing middleware mirroring the npmcorspackage's common options (origin,methods,allowedHeaders,credentials,maxAge). Answers a CORS preflightOPTIONSrequest directly, since nothing would otherwise be registered to handle it. See Cors.bx. - Added
boxExpressRateLimit()— fixed-window rate limiting mirroring the npmexpress-rate-limitpackage's common options (windowMs,max,keyGenerator), keyed byreq.ipby default. Sets the draft-standardRateLimit-*headers and responds429withRetry-Afteronce a key's count exceedsmax. See RateLimit.bx. - Added
boxExpressCsrf()— CSRF protection mirroring the classiccsurfpackage's session-based token strategy. Requiresreq.session(register afterboxExpressSession(), which it throws immediately about if missing); exposesreq.csrfToken(), validatesreq.body._csrf(or a request header) on every method other thanGET/HEAD/OPTIONS. See Csrf.bx. boxExpressStatic()/res.sendFile()now acceptoptions.maxAge(seconds) to setCache-Control: public, max-age=<n>alongside theETag/Last-Modifiedthey already set — off by default, no header at all unless asked for.- Added
boxExpressCacheStore()— aSessionstorebacked by BoxLang's owncache()service, so{ store: boxExpressCacheStore( "sessions" ) }makes sessions durable across restarts and shared across a cluster when the named cache is configured withobjectStore: "JDBCStore"(a real SQL table) instead of the in-memory default. See CacheStore.bx.