diff options
| author | Frank <[email protected]> | 2025-06-18 16:20:05 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-06-18 16:20:34 -0400 |
| commit | e054454109140883ef52c00d833d560896361f6c (patch) | |
| tree | 1529074e31011cbc67aa3d74db99ed0e43e7b79c /packages/function/src | |
| parent | a6142cf975915cd9031804c4c23ef644d3931d79 (diff) | |
| download | opencode-e054454109140883ef52c00d833d560896361f6c.tar.gz opencode-e054454109140883ef52c00d833d560896361f6c.zip | |
Api: only return session messages
Diffstat (limited to 'packages/function/src')
| -rw-r--r-- | packages/function/src/api.ts | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/function/src/api.ts b/packages/function/src/api.ts index a312b1280..e2a773453 100644 --- a/packages/function/src/api.ts +++ b/packages/function/src/api.ts @@ -19,9 +19,9 @@ export class SyncServer extends DurableObject<Env> { this.ctx.acceptWebSocket(server) const data = await this.ctx.storage.list() - for (const [key, content] of data.entries()) { - server.send(JSON.stringify({ key, content })) - } + Array.from(data.entries()) + .filter(([key, _]) => key.startsWith("session/")) + .map(([key, content]) => server.send(JSON.stringify({ key, content }))) return new Response(null, { status: 101, @@ -71,11 +71,9 @@ export class SyncServer extends DurableObject<Env> { public async getData() { const data = await this.ctx.storage.list() - const messages = [] - for (const [key, content] of data.entries()) { - messages.push({ key, content }) - } - return messages + return Array.from(data.entries()) + .filter(([key, _]) => key.startsWith("session/")) + .map(([key, content]) => ({ key, content })) } private async getSecret() { |
