bridge.mjs
28 lines 1.2 KB
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 1 day 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). Set NETLIFY_BLOBS_CONSISTENCY=strong on the **bridge** site for
14 // read-after-write on vector blobs (index → search); see Netlify Blobs docs. If strong mode errors
15 // at runtime (e.g. missing edge URL), unset the env or revert to eventual.
16 const consistency =
17 String(process.env.NETLIFY_BLOBS_CONSISTENCY || '')
18 .trim()
19 .toLowerCase() === 'strong'
20 ? 'strong'
21 : 'eventual';
22 globalThis.__netlify_blob_store = getStore({ name: 'bridge-data', consistency });
23 try {
24 return await serverless(app)(event, context);
25 } finally {
26 delete globalThis.__netlify_blob_store;
27 }
28 };
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 1 day ago