4bnode 4.0.4 → 4.0.6

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/README.md CHANGED
@@ -180,22 +180,16 @@ Access at `http://localhost:3000/_dev` when running `npm run dev`.
180
180
  ```
181
181
  my-app/
182
182
  ├── index.js # Express app entry point
183
- ├── dev-api.js # Dev dashboard API (auto-included)
184
183
  ├── package.json
185
184
  ├── .env.development # Dev environment variables
186
185
  ├── .env.production # Production environment variables
187
- ├── .4bnode/ # Dashboard data (tester, shared collections)
186
+ ├── .4bnode/ # Dashboard engine & data (managed by 4bnode)
188
187
  ├── public/ # Static files
189
- │ ├── index.html # Dashboard UI
190
- │ ├── fonts/
191
- │ └── images/
192
- ├── uploads/ # File uploads (when using multer)
188
+ │ └── index.html # App status landing page
193
189
  └── src/
194
190
  ├── db.js # MongoDB connection (after `add mongo`)
195
191
  ├── models/ # Mongoose schemas
196
- ├── routes/ # API route files
197
- └── middleware/
198
- └── auth.js # JWT auth middleware (after `add login`)
192
+ └── routes/ # API route files
199
193
  ```
200
194
 
201
195
  ## Real-time Communication
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4bnode",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "4bnode is a CLI-powered backend development platform with a built-in visual dashboard to generate, manage, and test Node.js/Express APIs faster.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,47 @@
1
+ # node-skeleton-app
2
+
3
+ Express 5 + Dotenv + CORS app, scaffolded by [4bnode](https://github.com/pawan-4brains/4bnode).
4
+
5
+ ## Getting started
6
+
7
+ ### 1. Install dependencies
8
+
9
+ ```bash
10
+ npm install
11
+ ```
12
+
13
+ ### 2. Configure environment
14
+
15
+ Edit `.env` in the project root and fill in the values your app needs:
16
+
17
+ ```bash
18
+ PORT=3000
19
+ # Add DATABASE_URL, API keys, etc. here
20
+ ```
21
+
22
+ ### 3. Run it
23
+
24
+ ```bash
25
+ npm run dev
26
+ ```
27
+
28
+ The app starts at `http://localhost:PORT` and the dev dashboard at `http://localhost:PORT/_dev`.
29
+
30
+ ## Project structure
31
+
32
+ ```
33
+ .
34
+ ├── index.js # Express app entry point
35
+ ├── package.json
36
+ ├── .env # Environment variables
37
+ ├── .4bnode/ # Dashboard engine & data (managed by 4bnode)
38
+ ├── public/ # Static files
39
+ └── src/
40
+ ├── db.js # MongoDB connection (after `4bnode add mongo`)
41
+ ├── models/ # Mongoose schemas
42
+ └── routes/ # API route files
43
+ ```
44
+
45
+ ## Extending with 4bnode
46
+
47
+ Run `4bnode add` inside this project to scaffold MongoDB, CRUD, login, sockets, and more. See the [4bnode README](https://github.com/pawan-4brains/4bnode) for the full feature list.
package/skeleton/index.js CHANGED
@@ -8,7 +8,7 @@ import { createInterface } from "readline";
8
8
 
9
9
  // ── Environment ─────────────────────────────────────
10
10
  const env = process.env.NODE_ENV || "development";
11
- dotenv.config({ path: `.env.${env}` });
11
+ dotenv.config();
12
12
 
13
13
  const app = express();
14
14
  const port = process.env.PORT || 3000;
@@ -44,16 +44,15 @@ function getLocalNetworkIp() {
44
44
  }
45
45
 
46
46
  function updateEnvPort(newPort) {
47
- const envFile = `.env.${env}`;
48
47
  try {
49
- if (fs.existsSync(envFile)) {
50
- let content = fs.readFileSync(envFile, "utf8");
48
+ if (fs.existsSync(".env")) {
49
+ let content = fs.readFileSync(".env", "utf8");
51
50
  if (content.match(/^PORT=.*/m)) {
52
51
  content = content.replace(/^PORT=.*/m, `PORT=${newPort}`);
53
52
  } else {
54
53
  content += `\nPORT=${newPort}`;
55
54
  }
56
- fs.writeFileSync(envFile, content, "utf8");
55
+ fs.writeFileSync(".env", content, "utf8");
57
56
  }
58
57
  } catch {}
59
58
  }
@@ -81,11 +80,16 @@ async function startServer(tryPort) {
81
80
  }
82
81
  if (tryPort !== Number(port)) {
83
82
  updateEnvPort(tryPort);
84
- console.log(`Updated .env.${env} with PORT=${tryPort}`);
83
+ console.log(`Updated .env with PORT=${tryPort}`);
85
84
  }
86
85
  });
87
86
  listener.on("error", async (err) => {
88
87
  if (err.code === "EADDRINUSE") {
88
+ if (!process.stdin.isTTY) {
89
+ // Running under pm2 / systemd / IntraApp — no terminal to prompt.
90
+ console.error(`Port ${tryPort} is in use and no TTY is available. Exiting.`);
91
+ process.exit(1);
92
+ }
89
93
  const nextPort = await askPort(tryPort);
90
94
  startServer(nextPort);
91
95
  } else {
@@ -1 +0,0 @@
1
- PORT=3000
File without changes