@tunframework/tun
Version:
tun framework for node with typescript
29 lines (28 loc) • 745 B
JavaScript
import { RAW_REQUEST } from './constants/http/symbol.js';
import { _getRequestCookieByName } from './TunCookie.js';
import { TunRequest } from './TunRequest.js';
import { TunResponse } from './TunResponse.js';
export class TunContext {
req;
res;
/**
* sth you may need to store and access
*/
state = {};
constructor(_req, _res) {
this.req = new TunRequest(_req);
this.res = new TunResponse(_req, _res);
}
/**
* shorthand for `res.body`
*/
get body() {
return this.res.body;
}
set body(val) {
this.res.body = val;
}
getRequestCookie(name) {
return _getRequestCookieByName(this.req[RAW_REQUEST], name);
}
}