{"version":3,"file":"responses.mjs","sources":["../../src/middlewares/responses.ts"],"sourcesContent":["import { isFunction } from 'lodash/fp';\nimport type { Common } from '@strapi/types';\n\nexport interface Config {\n  handlers?: Record<number, Common.MiddlewareHandler>;\n}\n\nexport const responses: Common.MiddlewareFactory<Config> = (config = {}) => {\n  return async (ctx, next) => {\n    await next();\n\n    const { status } = ctx;\n    const handler = config?.handlers?.[status];\n\n    if (isFunction(handler)) {\n      await handler(ctx, next);\n    }\n  };\n};\n"],"names":[],"mappings":";AAOO,MAAM,YAA8C,CAAC,SAAS,OAAO;AACnE,SAAA,OAAO,KAAK,SAAS;AAC1B,UAAM,KAAK;AAEL,UAAA,EAAE,OAAW,IAAA;AACb,UAAA,UAAU,QAAQ,WAAW,MAAM;AAErC,QAAA,WAAW,OAAO,GAAG;AACjB,YAAA,QAAQ,KAAK,IAAI;AAAA,IACzB;AAAA,EAAA;AAEJ;"}