Typescript SDK: Serve static assets from worker

Hello, we would like one of our activities to access a static file. Ideally we could host the static file on the workers server. Is there a way to configure the @temporalio/worker package to serve a directory?

We are using the typescript SDK.

If I understand your question correctly, this will depend on your worker process deployment (to include the directory as a binding maybe when you deploy, and expose it via endpoint).

Can you clarify what you mean by “serve a directory”?

Of course, lets say I have a folder structure like:

  • /src
    • worker.ts
  • /assets
    • image.png

The worker.ts starts a server process on localhost:3000. I’d like the worker server to be able to serve the assets directory such that localhost:3000/assets/image.png resolves to the image.

Got it, that makes sense. I was mostly curious whether the TypescriptSDK had any configurations to make this easier or if there was a canonical way to access static assets from the worker server (without loading from the local disk or an external resource).

A Temporal worker doesn’t serve HTTP traffic, I think you have some misconception.