yumechi-no-kuni/src/api/reply.ts

14 lines
286 B
TypeScript
Raw Normal View History

2016-12-28 16:49:51 -06:00
import * as express from 'express';
export default (res: express.Response, x?: any, y?: any) => {
if (x === undefined) {
res.sendStatus(204);
} else if (typeof x === 'number') {
res.status(x).send({
error: x === 500 ? 'INTERNAL_ERROR' : y
});
} else {
res.send(x);
}
};