lapeh 2.1.9 ā 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +25 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -27,6 +27,31 @@ const startServer = async () => {
|
|
|
27
27
|
// Initialize Redis transparently (no logs if missing)
|
|
28
28
|
await initRedis();
|
|
29
29
|
|
|
30
|
+
// Handle specific listen errors
|
|
31
|
+
server.on("error", (e: any) => {
|
|
32
|
+
if (e.code === "EADDRINUSE") {
|
|
33
|
+
console.log(`\nā Error: Port ${port} is already in use.`);
|
|
34
|
+
console.log(
|
|
35
|
+
`š” Suggestion: Run this command to kill the conflicting process:\n`
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (process.platform === "win32") {
|
|
39
|
+
console.log(` npx kill-port ${port}`);
|
|
40
|
+
console.log(
|
|
41
|
+
` (PowerShell): Stop-Process -Id (Get-NetTCPConnection -LocalPort ${port}).OwningProcess -Force`
|
|
42
|
+
);
|
|
43
|
+
} else if (process.platform === "darwin") {
|
|
44
|
+
console.log(` npx kill-port ${port}`);
|
|
45
|
+
console.log(` (Terminal): kill -9 $(lsof -t -i:${port})`);
|
|
46
|
+
} else {
|
|
47
|
+
// Linux
|
|
48
|
+
console.log(` npx kill-port ${port}`);
|
|
49
|
+
console.log(` (Terminal): fuser -k ${port}/tcp`);
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
30
55
|
server.listen(port, () => {
|
|
31
56
|
console.log(`ā
API running at http://localhost:${port}`);
|
|
32
57
|
console.log(`š”ļø Environment: ${process.env.NODE_ENV || "development"}`);
|