h-sifat / express-ipc

A simple IPC server with express-like request and route handling that also supports broadcasting to multiple channels.
MIT License
7 stars 0 forks source link

Adding a timeout on the client side if the server does not send a response #1

Closed damartripamungkas closed 7 months ago

damartripamungkas commented 7 months ago
// server.js
const server = new Server({ path: })
server.post("/", ({ req, res }) => {
  if (req.body == "ping") {
    res.send("pong");
  }
})

server.listen({
  path: "./test.ipc",
  callback: () => {
    console.log(`server ipc running`);
  },
});
// client.js
const client = new Client({ path: "./test.ipc" });
(async () => {
  const run = await client.post("/", {
    body: "anything lorem ipsum",
  });

  console.log({ run });
})();
h-sifat commented 7 months ago

Seems like a good idea. I'll try to add it this weekend.

By the way, if you don't mind I would love to know what are you using express-ipc for.

damartripamungkas commented 7 months ago

Seems like a good idea. I'll try to add it this weekend.

By the way, if you don't mind I would love to know what are you using express-ipc for.

This is pretty good for interaction between independently generated processes (child_process:spawn) since node.js doesn't provide it by default

h-sifat commented 7 months ago

Hello @damartripamungkas, finally I've published the new feature. Kindly read the docs for request methods (request, get, etc.). Thank you.