{"version":3,"file":"BgB2vgpx.js","sources":["../../../../src/middleware/process-subscription.ts"],"sourcesContent":["import type {CookieRef} from \"#app\";\nimport axios from \"axios\";\n\nexport default defineNuxtRouteMiddleware(async (to) => {\n const isAuthenticated = useCookie('isAuth')\n const url = useCookie('paymentUrl', {\n expires: new Date(new Date().getTime() + 30 * 1000)\n })\n\n if (import.meta.server) return\n\n if (isAuthenticated.value) {\n const authToken: CookieRef = useCookie('authToken')\n if (authToken.value !== '') {\n const config = useRuntimeConfig()\n const payment_service_url = config.public.services.payments\n const req = axios.create({baseURL: payment_service_url})\n req.defaults.headers.authorization = authToken.value\n\n const {data} = await req.post('/payments/create-link-promo', to.query)\n url.value = data.url\n\n } else {\n url.value = ''\n console.error(\"Parece que no ex válida la conexión.\")\n navigateTo('/dashboard/subscriptions')\n }\n } else {\n url.value = ''\n console.log(\"No está autenticado.\")\n }\n\n})"],"names":["processSubscription","defineNuxtRouteMiddleware","to","__temp","__restore","isAuthenticated","useCookie","url","authToken","payment_service_url","useRuntimeConfig","req","axios","__executeAsync","data","navigateTo"],"mappings":"yEAII,MAAMA,EAAAC,EAAoC,MAAAC,GAAA,CAAA,IAAAC,EAAAC,EACpC,MAAAC,EAA8BC,EAAA,QAAA,EAChCC,IAAkB,aAAA,CACrB,QAAA,IAAA,KAAA,IAAA,KAAA,EAAA,QAAA,EAAA,GAAA,GAAA,CAED,CAAA,EAGU,GAAAF,EAA+B,OACjC,MAAAG,IAAwB,WAAA,EACxB,GAAAA,UAAgC,GAAA,CAEhC,MAAMC,EADAC,IACoB,yBACtBC,EAAAC,EAAiB,OAAA,CAAA,QAAAH,CAA0B,CAAA,EAEzCE,EAAA,SAAK,QAAI,cAAAH,EAAA,MACf,YAAiB,GAAA,CAAAL,EAAAC,CAAA,EAAAS,EAAA,IAAAF,EAAA,KAAA,8BAAAT,EAAA,KAAA,CAAA,EAAAC,EAAA,MAAAA,EAAAC,IAAAD,GAEdI,EAAA,MAAAO,EAAA,GACH,MACAP,EAAA,SACA,QAAA,MAAqC,sCAAA,EACzCQ,EAAA,0BAAA,CAEA,MACAR,EAAA,MAAY,GAChB,QAAA,IAAA,sBAAA"}