Given the following JavaScript application running on Node on the Dapr runtime:
import { DaprServer, CommunicationProtocolEnum } from "@dapr/dapr";
import express from "express";
const myApp = express();
myApp.get("/my-custom-endpoint", (req, res) => {
res.send({ msg: "My own express app!" });
});
const daprServer = new DaprServer({
serverHost: "127.0.0.1",
serverPort: "3000",
serverHttp: myApp,
});
await daprServer.pubsub.subscribe("pubsub", "messages", async (messageId) => {
console.log(`Subscriber received: ${JSON.stringify(messageId)}`)
});
await daprServer.start();
In this example, we would like to use the daprServer instance to both:
- Expose HTTP API endpoints
- Listen to events from the
pubsubpubsub on themessagestopic
However when running this via dapr run --app-id background-with-api --app-port 3000 -- node main.js, event listening seems to be disabled.
The same setup is actually feasible with C# and asp.net core, since node now supports threads I don't see why this doesn't work with Javascript?
Am I missing something ?