Skip to content

Commit

Permalink
Decorating req.private, updating README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 7, 2021
1 parent bb07790 commit dcb5c51
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Unprotected routes are routes that do not require authorization for access, and
The `/assets/*` route is reserved for the HTML browsable interface assets; please do not try to reuse this for data.

### Request Helpers
Tenso decorates `req` with "helpers" such as `req.ip`, & `req.parsed`. `PATCH`, `PUT`, & `POST` payloads are available as `req.body`. Sessions are available as `req.session` when using `local` authentication.
Tenso decorates `req` with "helpers" such as `req.allow`, `req.csrf`, `req.ip`, `req.parsed`, & `req.private`. `PATCH`, `PUT`, & `POST` payloads are available as `req.body`. Sessions are available as `req.session` when using `local` authentication.

Tenso decorates `res` with "helpers" such as `res.send()`, `res.status()`, & `res.json()`.

Expand Down
3 changes: 2 additions & 1 deletion lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class Tenso extends Base {

connect (req, res) {
req.csrf = this.canModify(req.method) === false && this.canModify(req.allow) && this.config.security.csrf === true;
req.private = false;
req.hypermedia = true;
req.protect = false;
req.protectAsync = false;
Expand Down Expand Up @@ -193,7 +194,7 @@ class Tenso extends Base {
const key = "cache-control",
cache = res.getHeader(key) || "";

if (req.protect || req.csrf && cache.includes("private") === false) {
if ((req.protect || req.csrf || req.private) && cache.includes("private") === false) {
const lcache = cache.replace(/(private|public)(,\s)?/g, "");

res.removeHeader(key);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tenso is an HTTP REST API framework",
"version": "16.1.0",
"version": "16.2.0",
"homepage": "https://github.com/avoidwork/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit dcb5c51

Please sign in to comment.