{"version":3,"file":"favicon.mjs","sources":["../../src/middlewares/favicon.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport koaFavicon from 'koa-favicon';\nimport type { Core } from '@strapi/types';\n\nexport type Config = NonNullable[1]>;\n\nconst defaults = {\n path: 'favicon.png',\n maxAge: 86400000,\n};\n\nexport const favicon: Core.MiddlewareFactory = (config, { strapi }) => {\n const { maxAge, path: faviconDefaultPath } = { ...defaults, ...config };\n const { root: appRoot } = strapi.dirs.app;\n let faviconPath = faviconDefaultPath;\n\n /** TODO (v5): Updating the favicon to use a png caused\n * https://github.com/strapi/strapi/issues/14693\n *\n * This check ensures backwards compatibility until\n * the next major version\n */\n if (!existsSync(resolve(appRoot, faviconPath))) {\n faviconPath = 'favicon.ico';\n }\n\n return koaFavicon(resolve(appRoot, faviconPath), { maxAge });\n};\n"],"names":["defaults","path","maxAge","favicon","config","strapi","faviconDefaultPath","root","appRoot","dirs","app","faviconPath","existsSync","resolve","koaFavicon"],"mappings":";;;;AAOA,MAAMA,QAAW,GAAA;IACfC,IAAM,EAAA,aAAA;IACNC,MAAQ,EAAA;AACV,CAAA;MAEaC,OAA0C,GAAA,CAACC,MAAQ,EAAA,EAAEC,MAAM,EAAE,GAAA;AACxE,IAAA,MAAM,EAAEH,MAAM,EAAED,IAAMK,EAAAA,kBAAkB,EAAE,GAAG;AAAE,QAAA,GAAGN,QAAQ;AAAE,QAAA,GAAGI;AAAO,KAAA;IACtE,MAAM,EAAEG,MAAMC,OAAO,EAAE,GAAGH,MAAOI,CAAAA,IAAI,CAACC,GAAG;AACzC,IAAA,IAAIC,WAAcL,GAAAA,kBAAAA;AAElB;;;;;AAKC,MACD,IAAI,CAACM,UAAWC,CAAAA,OAAAA,CAAQL,SAASG,WAAe,CAAA,CAAA,EAAA;QAC9CA,WAAc,GAAA,aAAA;AAChB;IAEA,OAAOG,UAAAA,CAAWD,OAAQL,CAAAA,OAAAA,EAASG,WAAc,CAAA,EAAA;AAAET,QAAAA;AAAO,KAAA,CAAA;AAC5D;;;;"}