2014-01-14 17:13:47 -05:00
|
|
|
module.exports.custom = (res, code=500, message='Internal Server Error') ->
|
|
|
|
res.send code, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.unauthorized = (res, message='Unauthorized') ->
|
|
|
|
# TODO: The response MUST include a WWW-Authenticate header field
|
|
|
|
res.send 401, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.forbidden = (res, message='Forbidden') ->
|
|
|
|
res.send 403, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.notFound = (res, message='Not found.') ->
|
|
|
|
res.send 404, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
2014-06-09 11:28:35 -04:00
|
|
|
module.exports.badMethod = (res, allowed=['GET', 'POST', 'PUT', 'PATCH'], message='Method Not Allowed') ->
|
|
|
|
allowHeader = _.reduce allowed, ((str, current) -> str += ', ' + current)
|
|
|
|
res.set 'Allow', allowHeader # TODO not sure if these are always the case
|
2014-01-14 17:13:47 -05:00
|
|
|
res.send 405, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.conflict = (res, message='Conflict. File exists') ->
|
|
|
|
res.send 409, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.badInput = (res, message='Unprocessable Entity. Bad Input.') ->
|
|
|
|
res.send 422, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-01-14 17:13:47 -05:00
|
|
|
|
|
|
|
module.exports.serverError = (res, message='Internal Server Error') ->
|
|
|
|
res.send 500, message
|
2014-01-17 13:30:47 -05:00
|
|
|
res.end()
|
2014-02-07 15:36:56 -05:00
|
|
|
|
2014-06-30 22:16:26 -04:00
|
|
|
module.exports.gatewayTimeoutError = (res, message='Gateway timeout') ->
|
2014-02-07 15:36:56 -05:00
|
|
|
res.send 504, message
|
|
|
|
res.end()
|
2014-02-07 18:52:24 -05:00
|
|
|
|
2014-06-30 22:16:26 -04:00
|
|
|
module.exports.clientTimeout = (res, message='The server did not receive the client response in a timely manner') ->
|
2014-02-08 13:11:43 -05:00
|
|
|
res.send 408, message
|
2014-06-09 11:28:35 -04:00
|
|
|
res.end()
|