Params with streamInOut #1724
-
How i can use params with streamInOut? in my example i would like to get export const SyncProjectStream = api.streamInOut<InMessage, OutMessage>(
{ path: "/projects/:projectId/stream", expose: false, auth: false },
async (stream) => {
for await (const transaction of stream) {
console.log(transaction);
}
}
); |
Beta Was this translation helpful? Give feedback.
Answered by
copy-paste-repeat
Jan 18, 2025
Replies: 1 comment 1 reply
-
Example which is working for me import { api, StreamInOut } from "encore.dev/api";
import log from "encore.dev/log";
// Type definitions for messages
interface ProjectSyncHandshakeParams {
projectId: string; // Project identifier from the URL
clientId: string; // Unique client identifier
}
interface IncomingMessage {
data: any;
}
interface OutgoingMessage {
data: any;
}
export const projectSync = api.streamInOut<ProjectSyncHandshakeParams, IncomingMessage, OutgoingMessage>({ path: '/projects/:projectId', expose: true }, async (params, stream) => {
log.debug(params.projectId);
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
copy-paste-repeat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example which is working for me