simplex/helpers/api.moon

17 lines
337 B
Plaintext
Raw Normal View History

2018-04-25 00:28:23 +00:00
import json_params, capture_errors from require "lapis.application"
import remove from table
api_request = (fn) ->
json_params capture_errors {
fn,
on_error: =>
status = 400
if "number" == type @errors[1]
status = remove(@errors, 1)
return(:status, json: { errors: @errors })
}
{
:api_request
}