Skip to content

Commit 19ae55b

Browse files
authored
[board-server] Teach board server node proxy about data store groups.
- **Teach board server proxy about data store groups.** - **Teach secrets that `STORAGE_BACKEND` may be empty.** - **Bump the board server version.** - **docs(changeset): Teach board server node proxy about data store groups.**
1 parent 571dfcc commit 19ae55b

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

.changeset/itchy-carpets-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@breadboard-ai/board-server": patch
3+
---
4+
5+
Teach board server node proxy about data store groups.

packages/board-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"registry": "https://wombat-dressing-room.appspot.com"
55
},
66
"private": true,
7-
"version": "0.6.1",
7+
"version": "0.6.2",
88
"description": "Board Server",
99
"main": "./dist/server/index.js",
1010
"exports": "./dist/server/index.js",

packages/board-server/src/server/proxy/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,13 @@ export const serveProxyAPI = async (
9797
const server = new ProxyServer(
9898
new HTTPServerTransport({ body }, new ResponseAdapter(res))
9999
);
100+
const store = getDataStore();
101+
store.createGroup("run-board");
102+
100103
const tunnel = await buildSecretsTunnel();
101104
const config: ProxyServerConfig = {
102105
kits: [secretsKit, asRuntimeKit(Core)],
103-
store: getDataStore(),
106+
store,
104107
proxy: ["fetch", { node: "secrets", tunnel }],
105108
};
106109

@@ -110,5 +113,7 @@ export const serveProxyAPI = async (
110113
serverError(res, (e as Error).message);
111114
}
112115

116+
store.releaseAll();
117+
113118
return true;
114119
};

packages/board-server/src/server/proxy/secrets.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const url = import.meta.url;
1313

1414
const getProjectId = async () => {
1515
let backend = process.env.STORAGE_BACKEND;
16-
if (backend !== "firestore") {
16+
if (backend && backend !== "firestore") {
1717
// For now, return "none" if we're not using Firestore
1818
// backend.
1919
// TODO: Implement support for secret managers outside
@@ -90,22 +90,26 @@ const getKey = async (key: string) => {
9090
};
9191

9292
export const getSecretList = async (): Promise<SecretMapEntry[]> => {
93-
const [secrets] = await secretManager.listSecrets({
94-
parent: `projects/${PROJECT_ID}`,
95-
});
96-
const secretNames = secrets
97-
.map((s) => s.name?.split("/").pop())
98-
.filter(Boolean) as string[];
99-
const entries = await Promise.all(
100-
secretNames.map(async (name) => {
101-
const origin = await getAnnotation(name);
102-
if (!origin) {
103-
return null;
104-
}
105-
return { secret: name, origin };
106-
})
107-
);
108-
return entries.filter(Boolean) as SecretMapEntry[];
93+
try {
94+
const [secrets] = await secretManager.listSecrets({
95+
parent: `projects/${PROJECT_ID}`,
96+
});
97+
const secretNames = secrets
98+
.map((s) => s.name?.split("/").pop())
99+
.filter(Boolean) as string[];
100+
const entries = await Promise.all(
101+
secretNames.map(async (name) => {
102+
const origin = await getAnnotation(name);
103+
if (!origin) {
104+
return null;
105+
}
106+
return { secret: name, origin };
107+
})
108+
);
109+
return entries.filter(Boolean) as SecretMapEntry[];
110+
} catch (e) {
111+
throw new Error(`Failed to list secrets: ${e}`);
112+
}
109113
};
110114

111115
export const buildSecretsTunnel = async (): Promise<TunnelSpec> => {

0 commit comments

Comments
 (0)