4bnode 4.0.5 → 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/package.json +1 -1
- package/skeleton/.env +1 -0
- package/skeleton/README.md +7 -25
- package/skeleton/index.js +5 -7
- package/skeleton/.env.example +0 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "4bnode",
|
|
3
|
-
"version": "4.0.
|
|
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",
|
package/skeleton/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PORT=3000
|
package/skeleton/README.md
CHANGED
|
@@ -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
|
-
##
|
|
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.
|
|
13
|
+
### 2. Configure environment
|
|
14
14
|
|
|
15
|
-
|
|
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
|
-
|
|
27
|
-
#
|
|
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
|
|
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
|
|
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/
|
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(
|
|
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(
|
|
51
|
-
let content = fs.readFileSync(
|
|
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(
|
|
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
|
|
83
|
+
console.log(`Updated .env with PORT=${tryPort}`);
|
|
86
84
|
}
|
|
87
85
|
});
|
|
88
86
|
listener.on("error", async (err) => {
|
package/skeleton/.env.example
DELETED
|
@@ -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=
|