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

30 lines
655 B
TypeScript
Raw Normal View History

2020-04-03 15:00:49 +02:00
import consts from '@scode/consts';
2020-04-03 18:50:08 +02:00
import {Request, Response} from '@types/express';
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;
/* public */
public status: number = -1;
/* properties */
public get has_status(): boolean => this.status !== -1;
public get req(): Request => this._req;
public get res(): Response => this._res;
/* constructor */
2020-04-03 18:50:08 +02:00
public Transaction(req: Request,res: Response) {
2020-04-03 15:00:49 +02:00
this._req = req;
this._res = res;
}
/* methods */
2020-04-03 18:50:08 +02:00
public end(data: any) {
2020-04-03 15:00:49 +02:00
if (this.status !== -1)
2020-04-03 18:50:08 +02:00
this._res.status(this.status);
this._res.end(data);
2020-04-03 15:00:49 +02:00
}
}