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

import consts from '@scode/consts';
import {Request, Response} from '@types/express';
export default class Transaction {
/* 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 */
public Transaction(req: Request,res: Response) {
this._req = req;
this._res = res;
}
/* methods */
public end(data: any) {
if (this.status !== -1)
this._res.status(this.status);
this._res.end(data);
}
}