@tunframework/tun
Version:
tun framework for node with typescript
33 lines (32 loc) • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TunContext = void 0;
const symbol_js_1 = require("./constants/http/symbol.js");
const TunCookie_js_1 = require("./TunCookie.js");
const TunRequest_js_1 = require("./TunRequest.js");
const TunResponse_js_1 = require("./TunResponse.js");
class TunContext {
req;
res;
/**
* sth you may need to store and access
*/
state = {};
constructor(_req, _res) {
this.req = new TunRequest_js_1.TunRequest(_req);
this.res = new TunResponse_js_1.TunResponse(_req, _res);
}
/**
* shorthand for `res.body`
*/
get body() {
return this.res.body;
}
set body(val) {
this.res.body = val;
}
getRequestCookie(name) {
return (0, TunCookie_js_1._getRequestCookieByName)(this.req[symbol_js_1.RAW_REQUEST], name);
}
}
exports.TunContext = TunContext;