2016-03-19 16:58:27 +08:00
|
|
|
|
|
|
|
import {NextFunction, Request, Response} from "express";
|
|
|
|
import {Message} from "../../common/entities/Message";
|
|
|
|
import {Error} from "../../common/entities/Error";
|
|
|
|
|
|
|
|
export class BaseMWs {
|
|
|
|
|
|
|
|
protected static renderMessage<T>(res:Response, content:T){
|
2016-03-20 00:31:42 +08:00
|
|
|
let message = new Message<T> (null,content);
|
2016-03-19 16:58:27 +08:00
|
|
|
res.json(message);
|
|
|
|
}
|
|
|
|
protected static renderError(res:Response, error:Error){
|
2016-03-20 00:31:42 +08:00
|
|
|
let message = new Message<any> (error,null);
|
2016-03-19 16:58:27 +08:00
|
|
|
res.json(message);
|
|
|
|
}
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
public static renderOK(req:Request, res:Response, next:NextFunction){
|
|
|
|
let message = new Message<string> (null,"ok");
|
|
|
|
res.json(message);
|
|
|
|
}
|
2016-03-19 16:58:27 +08:00
|
|
|
}
|