4bnode 4.0.5 → 4.0.7

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/index.js CHANGED
@@ -97,6 +97,14 @@ async function createSkeletonApp(projectName) {
97
97
  }
98
98
  copyRecursiveSync(skeletonPath, targetPath);
99
99
  updatePackageName(targetPath, projectName);
100
+
101
+ // npm strips .gitignore from published packages — stored as _gitignore and renamed here.
102
+ const gitignoreSrc = path.join(targetPath, "_gitignore");
103
+ const gitignoreDest = path.join(targetPath, ".gitignore");
104
+ if (fs.existsSync(gitignoreSrc)) {
105
+ fs.renameSync(gitignoreSrc, gitignoreDest);
106
+ }
107
+
100
108
  scaffoldSpinner.succeed(chalk.hex("#00f260").bold("Project scaffolded"));
101
109
 
102
110
  // Ask for dashboard passkey
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4bnode",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
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",
package/skeleton/.env ADDED
@@ -0,0 +1 @@
1
+ PORT=3000
@@ -2,7 +2,7 @@
2
2
 
3
3
  Express 5 + Dotenv + CORS app, scaffolded by [4bnode](https://github.com/pawan-4brains/4bnode).
4
4
 
5
- ## Bootstrap (new machine / fresh clone)
5
+ ## Getting started
6
6
 
7
7
  ### 1. Install dependencies
8
8
 
@@ -10,21 +10,13 @@ Express 5 + Dotenv + CORS app, scaffolded by [4bnode](https://github.com/pawan-4
10
10
  npm install
11
11
  ```
12
12
 
13
- ### 2. Get the env file
13
+ ### 2. Configure environment
14
14
 
15
- This project keeps secrets out of git. Pick the source that applies:
16
-
17
- | You are | Get values from |
18
- |---|---|
19
- | Setting up local dev | Bitwarden item: **`4bnode-<project-name> · .env.development`** |
20
- | Bringing up a new prod deployment | IntraApp → Deployments → `<deployment>` → Environment variables |
21
- | You have neither | Ping #dev-platform on Slack with the project name |
22
-
23
- Once you have the values:
15
+ Edit `.env` in the project root and fill in the values your app needs:
24
16
 
25
17
  ```bash
26
- cp .env.example .env.development
27
- # then edit .env.development and fill in the real values
18
+ PORT=3000
19
+ # Add DATABASE_URL, API keys, etc. here
28
20
  ```
29
21
 
30
22
  ### 3. Run it
@@ -33,16 +25,7 @@ cp .env.example .env.development
33
25
  npm run dev
34
26
  ```
35
27
 
36
- The app starts at `http://localhost:$PORT` and the dev dashboard at `http://localhost:$PORT/_dev`.
37
-
38
- ### 4. When you add a new env variable
39
-
40
- 1. Add it to your local `.env.development` with a real value.
41
- 2. Add it to `.env.example` with a placeholder. Commit the change.
42
- 3. Add the real production value in **IntraApp → Environment variables**.
43
- 4. Update the Bitwarden item if other devs need the same value locally.
44
-
45
- This four-step rule keeps every developer in sync without ever touching git history.
28
+ The app starts at `http://localhost:PORT` and the dev dashboard at `http://localhost:PORT/_dev`.
46
29
 
47
30
  ## Project structure
48
31
 
@@ -50,8 +33,7 @@ This four-step rule keeps every developer in sync without ever touching git hist
50
33
  .
51
34
  ├── index.js # Express app entry point
52
35
  ├── package.json
53
- ├── .env.example # Committed — documents required keys
54
- ├── .env.development # Gitignored — your local values
36
+ ├── .env # Environment variables
55
37
  ├── .4bnode/ # Dashboard engine & data (managed by 4bnode)
56
38
  ├── public/ # Static files
57
39
  └── src/
@@ -0,0 +1,19 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ build/
7
+ .next/
8
+
9
+ # Logs
10
+ *.log
11
+ npm-debug.log*
12
+ yarn-debug.log*
13
+ yarn-error.log*
14
+
15
+ # Editor / OS
16
+ .DS_Store
17
+ .vscode/
18
+ .idea/
19
+ *.swp
package/skeleton/index.js CHANGED
@@ -8,8 +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}` }); // local dev: .env.development / .env.production
12
- dotenv.config(); // IntraApp prod: plain .env (won't override existing)
11
+ dotenv.config();
13
12
 
14
13
  const app = express();
15
14
  const port = process.env.PORT || 3000;
@@ -45,16 +44,15 @@ function getLocalNetworkIp() {
45
44
  }
46
45
 
47
46
  function updateEnvPort(newPort) {
48
- const envFile = `.env.${env}`;
49
47
  try {
50
- if (fs.existsSync(envFile)) {
51
- let content = fs.readFileSync(envFile, "utf8");
48
+ if (fs.existsSync(".env")) {
49
+ let content = fs.readFileSync(".env", "utf8");
52
50
  if (content.match(/^PORT=.*/m)) {
53
51
  content = content.replace(/^PORT=.*/m, `PORT=${newPort}`);
54
52
  } else {
55
53
  content += `\nPORT=${newPort}`;
56
54
  }
57
- fs.writeFileSync(envFile, content, "utf8");
55
+ fs.writeFileSync(".env", content, "utf8");
58
56
  }
59
57
  } catch {}
60
58
  }
@@ -82,7 +80,7 @@ async function startServer(tryPort) {
82
80
  }
83
81
  if (tryPort !== Number(port)) {
84
82
  updateEnvPort(tryPort);
85
- console.log(`Updated .env.${env} with PORT=${tryPort}`);
83
+ console.log(`Updated .env with PORT=${tryPort}`);
86
84
  }
87
85
  });
88
86
  listener.on("error", async (err) => {
@@ -1,29 +0,0 @@
1
- # ──────────────────────────────────────────────────
2
- # 4Brains Node project — environment variables
3
- #
4
- # Copy this file:
5
- # cp .env.example .env.development
6
- # then fill in real values for local dev.
7
- #
8
- # Production values are managed in IntraApp:
9
- # IntraApp → Deployments → <your-app> → ⋯ → Environment variables
10
- # ──────────────────────────────────────────────────
11
-
12
- # --- Runtime ---
13
- NODE_ENV=development
14
- PORT=3000
15
-
16
- # --- Database (uncomment after `4bnode add mongo`) ---
17
- # MONGO_URI=mongodb://127.0.0.1:27017/your-db-name
18
-
19
- # --- Auth (uncomment after `4bnode add login`) ---
20
- # JWT_SECRET=replace-with-a-long-random-string-min-32-chars
21
-
22
- # --- External services (uncomment as you add them) ---
23
- # SMTP_HOST=
24
- # SMTP_PORT=
25
- # SMTP_USER=
26
- # SMTP_PASSWORD=
27
- # TWILIO_ACCOUNT_SID=
28
- # TWILIO_AUTH_TOKEN=
29
- # MICROSOFT_CLIENT_ID=