1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-15 15:18:08 +09:00
hotomoe/src/api/reply.ts
2016-12-29 07:49:51 +09:00

14 lines
286 B
TypeScript

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);
}
};