bridge.mjs
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9
docs: move durable-auth freeze/evidence to local developmen…
Human
11 days ago
| 1 | /** |
| 2 | * Netlify serverless wrapper for the Knowtation Hub Bridge. |
| 3 | * Use this when you deploy the bridge as a second Netlify site (same repo, redirect to this function). |
| 4 | * Set the bridge env vars in that site's dashboard; set BRIDGE_URL on the gateway to that site's URL. |
| 5 | * Attaches Netlify Blob store for persistent tokens + vector DBs. |
| 6 | */ |
| 7 | import serverless from 'serverless-http'; |
| 8 | import { connectLambda, getStore } from '@netlify/blobs'; |
| 9 | import { app } from '../../hub/bridge/server.mjs'; |
| 10 | |
| 11 | export const handler = async (event, context) => { |
| 12 | connectLambda(event); |
| 13 | // Default `eventual` (fast) for the store handle. Calendar OAuth hydrate still passes |
| 14 | // `consistency: 'strong'` per get (see hub/bridge/calendar-blob-store.mjs) so begin→callback |
| 15 | // read-after-write does not return state_invalid. Set NETLIFY_BLOBS_CONSISTENCY=strong on the |
| 16 | // **bridge** site to also force strong for index/vector reads; see Netlify Blobs docs. |
| 17 | const consistency = |
| 18 | String(process.env.NETLIFY_BLOBS_CONSISTENCY || '') |
| 19 | .trim() |
| 20 | .toLowerCase() === 'strong' |
| 21 | ? 'strong' |
| 22 | : 'eventual'; |
| 23 | globalThis.__netlify_blob_store = getStore({ name: 'bridge-data', consistency }); |
| 24 | try { |
| 25 | return await serverless(app)(event, context); |
| 26 | } finally { |
| 27 | delete globalThis.__netlify_blob_store; |
| 28 | } |
| 29 | }; |
File History
1 commit
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9
docs: move durable-auth freeze/evidence to local developmen…
Human
11 days ago