bridge.mjs
28 lines 1.2 KB
Raw
sha256:8d46372e39d2d5a54fd93a8b1c27922fe0d9b22a72197345f1d2c71701cc4ce2 feat(auth): persistent login system + C7 session introspection Human minor ⚠ breaking 17 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). 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 2 commits
sha256:8d46372e39d2d5a54fd93a8b1c27922fe0d9b22a72197345f1d2c71701cc4ce2 feat(auth): persistent login system + C7 session introspection Human minor 17 days ago