All files / lib/util apiResponse.ts

37.5% Statements 3/8
20% Branches 1/5
50% Functions 1/2
37.5% Lines 3/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                                        1x   1x 1x      
export default {
  error(err?, info = {}) {
    const result: {
      ok: boolean
      info: object
      error?: any
    } = {
      ok: false,
      info,
    }
 
    if (err instanceof Error) {
      result.error = err.toString()
    } else {
      result.error = err
    }
 
    return result
  },
  success(data?) {
    const result = data || {}
 
    result.ok = true
    return result
  },
}