Set content type for responses.

This commit is contained in:
Mike Cao 2022-03-18 21:01:32 -07:00
parent f24696de5a
commit 63bfa616f1

View File

@ -6,14 +6,12 @@ export function json(res, data = {}) {
return res.status(200).json(data);
}
export function send(res, data) {
return res.status(200).send(data);
export function send(res, data, type = 'text-plain') {
return res.status(200).setHeader('Content-Type', type).send(data);
}
export function redirect(res, url) {
res.setHeader('Location', url);
return res.status(303).end();
return res.status(303).setHeader('Location', url).end();
}
export function badRequest(res, msg = '400 Bad Request') {