1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-16 11:37:13 +02:00
pigallery2/backend/middlewares/BaseMWs.ts
2016-03-19 17:31:42 +01:00

21 lines
663 B
TypeScript

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){
let message = new Message<T> (null,content);
res.json(message);
}
protected static renderError(res:Response, error:Error){
let message = new Message<any> (error,null);
res.json(message);
}
public static renderOK(req:Request, res:Response, next:NextFunction){
let message = new Message<string> (null,"ok");
res.json(message);
}
}