30 lines
655 B
TypeScript
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);
|
|
}
|
|
}
|