{"version":3,"sources":["jsdelivr-header.js","/npm/@growsari/response@0.0.3/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,KAAO,QAAQ,WAErB,SAAS,SAAS,GAChB,GAA0B,SAAtB,QAAQ,IAAI,MAAkB,CAChC,MAAM,EAAU,OAChB,QAAQ,MAAM,IAAI,eAAqB,EAAK,kBAAkB,KAAK,UAAU,cAAiB,EAAK,QACrG,CACF,CAEA,SAAS,QAAQ,GACf,MAAO,CACL,SAAS,EACT,QAAS,GACT,OAEJ,CAEA,SAAS,MAAM,GAEb,GADA,SAAS,GACc,QAAnB,EAAK,UAIT,MAAO,CACL,SAAS,EACT,QAAS,EAAK,QACd,KAAM,EAAK,KACX,UAAW,EAAK,UAEpB,CAEA,SAAS,UAAU,GACjB,GAAuB,QAAnB,EAAK,UAKT,MAAO,CACL,WAAY,EAAK,gBAAkB,IACnC,KAAM,KAAK,UAAU,MAAM,GAAO,KAAM,IALxC,SAAS,EAOb,CAEA,SAAS,YAAY,GACnB,MAAO,CACL,WAAY,IACZ,KAAM,KAAK,UAAU,QAAQ,GAAO,KAAM,GAE9C,CAEA,OAAO,QAAU,CACf,aAAc,CACZ,YACA,iBAEF,IAAK,CACH,MAAO,UACP,QAAS","file":"/npm/@growsari/response@0.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@growsari/response@0.0.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const uuid = require('uuid/v4')\n\nfunction logError(data) {\n  if (process.env.STAGE !== 'test') {\n    const errorId = uuid()\n    console.error(`[${errorId}] Message: ${data.message}. Data: ${JSON.stringify(data)}. Stack: ${data.stack}`)\n  }\n}\n\nfunction success(data) {\n  return {\n    success: true,\n    message: \"\",\n    data\n  }\n}\n\nfunction error(data) {\n  logError(data)\n  if (data.errorCode === '156') {\n    // Blocked. Duplicate request\n    return\n  }\n  return {\n    success: false,\n    message: data.message,\n    data: data.data,\n    errorCode: data.errorCode\n  }\n}\n\nfunction httpError(data) {\n  if (data.errorCode === '156') {\n    // Blocked. Duplicate request\n    logError(data)\n    return\n  }\n  return {\n    statusCode: data.httpStatusCode || 500,\n    body: JSON.stringify(error(data), null, 2)\n  }\n}\n\nfunction httpSuccess(data) {\n  return {\n    statusCode: 200,\n    body: JSON.stringify(success(data), null, 2)\n  }\n}\n\nmodule.exports = {\n  microservice: {\n    error,\n    success\n  }, \n  api: {\n    error: httpError,\n    success: httpSuccess\n  }\n}"]}