@komputing.xyz/hermes
v0.0.1
Published
TypeScript TCP networking server
Readme
✨ Features
- 🚀 Simple API for defining routes with
app.on(route, handler) - 🔌 TCP socket-based communication
- 🛠 Customizable logging
- 🧹 Clean server lifecycle management (
listen,close) - 🧪 Easy to test with Node's
netmodule or any TCP client likenetcat
📦 Installation
npm install @komputing.xyz/hermes▶️ Usage
💾 Example Server
import { Hermes } from "@komputing.xyz/hermes";
const app = new Hermes({ port: 8989, logging: true });
app.on("/hello", (data, send) => {
send(`Hello, ${data || "world"}!`);
});
app.listen();
// Graceful shutdown
process.on("exit", () => app.close());
process.on("SIGINT", () => app.close());
process.on("SIGTERM", () => app.close());💻 Example Client
import net from "net";
const client = net.createConnection(8989, "127.0.0.1", () => {
client.write("/hello Alice\n");
});
client.on("data", (data) => {
console.log("Server response:", data.toString().trim());
client.end();
});⌨️ Or via the commandline
netcat 127.0.0.1 8989
/hello Alice📜 License
MIT
📬 Contact
Komputing - @komputing.xyz - [email protected]
