#Need help integrating sockets

11 messages · Page 1 of 1 (latest)

tropic badge
#

I am trying to integrate sockets in medusa.js for a project, as the client has requested that I use sockets.

The issue I am getting is that I want to run the socket server on the same port as the Medusa server, but I haven't gotten any clue how to do this. I can create a loader for this, but unfortunately, I don't have access to the Express server that Medusa is running on

So if anyone has an idea on how we can do this, please let me know. I would really appreciate it. Thanks 🙂

vestal belfry
#

custom loader to integrate it with Medusa's Express server

tropic badge
#

I have tried it as well

vestal belfry
#

ao '

#

so

#

const { stream, abort } = await sdk.client.fetchStream("oath)

#

Medusa provides a built-in fetchStream

vestal belfry
tropic badge
tropic badge
vestal belfry
#

import { sdk } from "@medusajs/js-sdk"

const startStream = async () => {
const { stream, abort } = await sdk.client.fetchStream("/admin/stream")

if (stream) {
for await (const chunk of stream) {
const message = typeof chunk === "string" ? chunk : (chunk.data || String(chunk))
console.log('Stream data:', message)
}
}
}