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/transaction.ts

29 lines
700 B
TypeScript
Raw Normal View History

2020-04-08 11:57:30 +02:00
import { Request, Response } from '@types/express/index.d.ts';
import Status from './status.ts';
2020-04-03 15:00:49 +02:00
2020-04-03 18:50:08 +02:00
export default class Transaction {
2020-04-03 15:00:49 +02:00
/* private */
private _req: Request;
private _res: Response;
2020-04-08 11:57:30 +02:00
private _status: Status;
2020-04-03 15:00:49 +02:00
/* properties */
2020-04-08 11:57:30 +02:00
public get req (): Request { return this._req; }
public get res (): Response { return this._res; }
public get status (): Status { return this._status; }
2020-04-03 15:00:49 +02:00
/* constructor */
2020-04-08 11:57:30 +02:00
public constructor (req: Request, res: Response) {
2020-04-03 15:00:49 +02:00
this._req = req;
this._res = res;
2020-04-08 11:57:30 +02:00
this._status = new Status;
2020-04-03 15:00:49 +02:00
}
/* methods */
2020-04-08 11:57:30 +02:00
public end (data): void {
2020-04-03 15:00:49 +02:00
if (this.status !== -1)
2020-04-08 11:57:30 +02:00
this._res.status (this.status);
this._res.end (data);
2020-04-03 15:00:49 +02:00
}
}