simplex/helpers/api.moon
2018-04-24 17:28:23 -07:00

17 lines
337 B
Plaintext

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
}