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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapeh",
3
- "version": "2.1.9",
3
+ "version": "2.2.0",
4
4
  "description": "Framework API Express yang siap pakai (Standardized)",
5
5
  "main": "index.js",
6
6
  "bin": {
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"}`);