This repository has been archived on 2020-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
requestor/lib/classes/Transaction.ts
2020-04-09 12:29:30 +02:00

34 lines
778 B
TypeScript

import { Request, Response } from 'express';
import { http } from '@scode/consts';
import Session from './Session';
export default class Transaction {
/* private */
private _req: Request;
private _res: Response;
/* public */
public status = -1;
public session?: Session;
public get req (): Request { return this._req; }
public get res (): Response { return this._res; }
public get has_status (): boolean {
return Object.values (http.status_codes)
.includes (this.status);
}
/* constructor */
public constructor (req: Request, res: Response) {
this._req = req;
this._res = res;
}
/* methods */
public finalize (data?: any): void {
if (this.has_status)
this._res.status (this.status);
this._res.end (data);
}
}