MCPcopy Create free account
hub / github.com/avoidwork/tenso / connect

Method connect

src/tenso.js:100–117  ·  view source on GitHub ↗

* Handles connection setup for incoming requests * @param {Object} req - Request object * @param {Object} res - Response object * @returns {void}

(req, res)

Source from the content-addressed store, hash-verified

98 * @returns {void}
99 */
100 connect (req, res) {
101 req.csrf = this.canModify(req.method) === false && this.canModify(req.allow) && this.security.csrf === true;
102 req.hypermedia = this.hypermedia.enabled;
103 req.hypermediaHeader = this.hypermedia.header;
104 req.private = false;
105 req.protect = false;
106 req.protectAsync = false;
107 req.unprotect = false;
108 req.url = req.parsed.pathname;
109 req.server = this;
110
111 if (req.cors) {
112 const header = `${ACCESS_CONTROL}${HYPHEN}${req.method === OPTIONS ? ALLOW : EXPOSE}${HYPHEN}${HEADERS}`;
113
114 res.removeHeader(header);
115 res.header(header, `${EXPOSE_HEADERS}${req.csrf ? `, ${this.security.key}` : EMPTY}${this.corsExpose.length > INT_0 ? `, ${this.corsExpose}` : EMPTY}`);
116 }
117 }
118
119 /**
120 * Creates an EventSource instance

Callers

nothing calls this directly

Calls 3

canModifyMethod · 0.95
removeHeaderMethod · 0.80
headerMethod · 0.80

Tested by

no test coverage detected