diff --git a/package-lock.json b/package-lock.json index 16afbc3..45e1265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "devDependencies": { "@cloudflare/workers-types": "^4.20240423.0", "typescript": "^5.0.4", - "wrangler": "^3.56.0" + "wrangler": "^3.57.1" } }, "node_modules/@cfworker/jwt": { @@ -1320,9 +1320,9 @@ } }, "node_modules/wrangler": { - "version": "3.56.0", - "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.56.0.tgz", - "integrity": "sha512-YEUscEmg6F7nVPoNX5uaQ/KT0ztkPLLN4XGOl9uwgLCTHsyilzeh4WvEg6lelDi60EIXhuzWLjf0jBFN4wbnZw==", + "version": "3.57.1", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.57.1.tgz", + "integrity": "sha512-M8YnWUwdrb8AFiRePtVnzlDn02OX4osWvdl8oVh6eyZqqkqXYg7lwlYBr14Qj92pMN4JvMBmDZoukkYHvwpJRg==", "dev": true, "dependencies": { "@cloudflare/kv-asset-handler": "0.3.2", diff --git a/package.json b/package.json index 29c7e05..f753565 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "devDependencies": { "@cloudflare/workers-types": "^4.20240423.0", "typescript": "^5.0.4", - "wrangler": "^3.56.0" + "wrangler": "^3.57.1" }, "dependencies": { "@cfworker/jwt": "^4.0.6", diff --git a/src/index.ts b/src/index.ts index 96fa349..a34ccce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -145,7 +145,14 @@ app.post("/search", async (c) => { if (data.filter) { let filter: string = data.filter; if (filter.indexOf("(podcastName eq '") == 0) { - let query = filter.slice(17, -2); + const idFilter = "') and (id eq "; + let filterCutoff = -2; + if (filter.indexOf(idFilter) >= 0) { + filterCutoff = filterCutoff = filter.indexOf(idFilter); + const episodeId = filter.slice(filterCutoff + idFilter.length, -2); + dataPoint.blobs!.push(episodeId); + } + let query = filter.slice(17, filterCutoff); if (index) { index += " podcast=" + query; } else { @@ -190,7 +197,11 @@ app.post("/search", async (c) => { }); if (dataPoint) { dataPoint.blobs?.push(response.status.toString()); - c.env.Analytics.writeDataPoint(dataPoint); + try { + c.env.Analytics.writeDataPoint(dataPoint); + } catch (error) { + console.log(error); + } } c.header("Cache-Control", "max-age=600"); @@ -380,7 +391,6 @@ app.get("/podcasts", auth0Middleware, async (c) => { return c.json({ error: "Unauthorised" }, 403); }); - app.get("/discovery-curation", auth0Middleware, async (c) => { const auth0Payload: Auth0JwtPayload = c.var.auth0('payload'); c.header("Cache-Control", "max-age=600");