4bnode 1.1.1 → 3.5.2

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
@@ -1,116 +1,106 @@
1
- # 4Brains Node Tool
1
+ # 4Brains Node Generator
2
2
 
3
- A professional tool to streamline the generation and management of Node.js applications by 4Brains Technologies.
3
+ A comprehensive CLI tool to streamline the generation and management of Node.js applications by 4Brains Technologies.
4
4
 
5
- ## Usage via NPX
5
+ ## Installation
6
6
 
7
- No global installation needed.
8
-
9
- Run any command using `npx`:
10
-
11
- ```sh
12
- npx 4bnode <command>
13
- ```
14
-
15
- Examples:
7
+ To install the 4Brains Node Generator globally, use the following command:
16
8
 
17
9
  ```sh
18
- npx 4bnode init my-project
19
- npx 4bnode add-mongo
20
- npx 4bnode add-serialport
10
+ npm install -g 4brains-node-generator
21
11
  ```
22
12
 
23
13
  ## Available Commands
24
14
 
25
- ### `npx 4bnode init <projectName>`
15
+ ### `node-app init <projectName>`
26
16
 
27
17
  Initialize a new Node.js project with the specified name.
28
18
 
29
19
  ```sh
30
- npx 4bnode init my-project
20
+ node-app init my-project
31
21
  ```
32
22
 
33
- ### `npx 4bnode add-api <endpointName>`
23
+ ### `node-app add-api <endpointName>`
34
24
 
35
25
  Add a new API endpoint to your project.
36
26
 
37
27
  ```sh
38
- npx 4bnode add-api users
28
+ node-app add-api users
39
29
  ```
40
30
 
41
- ### `npx 4bnode add-mongo`
31
+ ### `node-app add-mongo`
42
32
 
43
33
  Integrate MongoDB into your project. This command sets up the necessary MongoDB configuration.
44
34
 
45
35
  ```sh
46
- npx 4bnode add-mongo
36
+ node-app add-mongo
47
37
  ```
48
38
 
49
- ### `npx 4bnode add-mongo-schema <schemaName>`
39
+ ### `node-app add-mongo-schema <schemaName>`
50
40
 
51
41
  Create a new MongoDB schema. You will be prompted to enter field details for the schema.
52
42
 
53
43
  ```sh
54
- npx 4bnode add-mongo-schema User
44
+ node-app add-mongo-schema User
55
45
  ```
56
46
 
57
- ### `npx 4bnode add-login`
47
+ ### `node-app add-login`
58
48
 
59
49
  Add a login template to an existing route in your project. You will be prompted to select a route and a model, and then enter the login fields.
60
50
 
61
51
  ```sh
62
- npx 4bnode add-login
52
+ node-app add-login
63
53
  ```
64
54
 
65
- ### `npx 4bnode add-mongo-insert`
55
+ ### `node-app add-mongo-insert`
66
56
 
67
57
  Add a template for inserting data into a MongoDB collection. This command allows you to easily create routes for data insertion.
68
58
 
69
59
  ```sh
70
- npx 4bnode add-mongo-insert
60
+ node-app add-mongo-insert
71
61
  ```
72
62
 
73
- ### `npx 4bnode add-mongo-update`
63
+ ### `node-app add-mongo-update`
74
64
 
75
65
  Add a template for updating data in a MongoDB collection. This facilitates creating routes for updating documents.
76
66
 
77
67
  ```sh
78
- npx 4bnode add-mongo-update
68
+ node-app add-mongo-update
79
69
  ```
80
70
 
81
- ### `npx 4bnode add-mongo-read`
71
+ ### `node-app add-mongo-read`
82
72
 
83
73
  Add a template for reading data from a MongoDB collection, helping you to quickly set up read operations.
84
74
 
85
75
  ```sh
86
- npx 4bnode add-mongo-read
76
+ node-app add-mongo-read
87
77
  ```
88
78
 
89
- ### `npx 4bnode add-mongo-delete`
79
+ ### `node-app add-mongo-delete`
90
80
 
91
81
  Add a template for deleting data from a MongoDB collection, making it easy to handle deletion operations.
92
82
 
93
83
  ```sh
94
- npx 4bnode add-mongo-delete
84
+ node-app add-mongo-delete
95
85
  ```
96
86
 
97
- ### `npx 4bnode add-socket`
87
+ ### `node-app add-socket`
98
88
 
99
89
  Integrate Socket.io into your project for real-time communication capabilities.
100
90
 
101
91
  ```sh
102
- npx 4bnode add-socket
92
+ node-app add-socket
103
93
  ```
104
94
 
105
- ### `npx 4bnode add-websocket`
95
+ ### `node-app add-websocket`
106
96
 
107
97
  Add native WebSocket support to your project.
108
98
 
109
99
  ```sh
110
- npx 4bnode add-websocket
100
+ node-app add-websocket
111
101
  ```
112
102
 
113
- ### `npx 4bnode add-serialport`
103
+ ### `node-app add-serialport`
114
104
 
115
105
  Integrate SerialPort functionality into your project. This command does the following:
116
106
 
@@ -120,7 +110,7 @@ Integrate SerialPort functionality into your project. This command does the foll
120
110
  - Installs required dependencies: `serialport` and `@serialport/parser-readline`
121
111
 
122
112
  ```sh
123
- npx 4bnode add-serialport
113
+ node-app add-serialport
124
114
  ```
125
115
 
126
116
  Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.
@@ -138,7 +128,7 @@ Received data: <data from serial device>
138
128
  When you run the command to add a MongoDB schema, you will be prompted to enter the field details.
139
129
 
140
130
  ```sh
141
- npx 4bnode add-mongo-schema User
131
+ node-app add-mongo-schema User
142
132
  ```
143
133
 
144
134
  ### Adding a Login Template
@@ -146,7 +136,7 @@ npx 4bnode add-mongo-schema User
146
136
  When you run the command to add a login template, you will be prompted to select a route and a model, and then enter the login fields.
147
137
 
148
138
  ```sh
149
- npx 4bnode add-login
139
+ node-app add-login
150
140
  ```
151
141
 
152
142
  ## Real-time Communication Integration
@@ -156,7 +146,7 @@ npx 4bnode add-login
156
146
  When you add WebSocket integration, it will automatically be added to your project.
157
147
 
158
148
  ```sh
159
- npx 4bnode add-websocket
149
+ node-app add-websocket
160
150
  ```
161
151
 
162
152
  To use `req.wss` in your route endpoints, you can access the WebSocket server as follows:
@@ -177,7 +167,7 @@ router.get("/some-endpoint", (req, res) => {
177
167
  When you add Socket.io integration, it will automatically be added to your project.
178
168
 
179
169
  ```sh
180
- npx 4bnode add-socket
170
+ node-app add-socket
181
171
  ```
182
172
 
183
173
  To use `req.io` in your route endpoints, you can access the Socket.io server as follows:
@@ -200,18 +190,10 @@ Unknown command. Use -h or --help for help.
200
190
  You can also use `-h` or `--help` to get help information.
201
191
 
202
192
  ```sh
203
- npx 4bnode -h
204
- npx 4bnode --help
193
+ node-app -h
194
+ node-app --help
205
195
  ```
206
196
 
207
197
  ## License
208
198
 
209
- Proprietary License
210
-
211
- © 2025 4Brains Technologies. All rights reserved.
212
-
213
- This software is proprietary and confidential. Unauthorized copying, distribution, modification, or use of this code, in whole or in part, is strictly prohibited.
214
-
215
- The contents of this package may not be used for any purpose without the express written permission of 4Brains Technologies.
216
-
217
- For licensing or commercial use inquiries, contact: contact@4brains.in
199
+ This project is licensed under the ISC License.
@@ -0,0 +1,197 @@
1
+ # 4Brains Node Generator
2
+
3
+ A comprehensive CLI tool to streamline the generation and management of Node.js applications by 4Brains Technologies.
4
+
5
+ ## Installation
6
+
7
+ To install the 4Brains Node Generator globally, use the following command:
8
+
9
+ ```sh
10
+ npm install -g 4brains-node-generator
11
+ ```
12
+
13
+ ## Available Commands
14
+
15
+ ### `4bnode init <projectName>`
16
+
17
+ Initialize a new Node.js project with the specified name.
18
+
19
+ ```sh
20
+ 4bnode init my-project
21
+ ```
22
+
23
+ ### `4bnode add-api <endpointName>`
24
+
25
+ Add a new API endpoint to your project.
26
+
27
+ ```sh
28
+ 4bnode add-api users
29
+ ```
30
+
31
+ ### `4bnode add-mongo`
32
+
33
+ Integrate MongoDB into your project. This command sets up the necessary MongoDB configuration.
34
+
35
+ ```sh
36
+ 4bnode add-mongo
37
+ ```
38
+
39
+ ### `4bnode add-mongo-schema <schemaName>`
40
+
41
+ Create a new MongoDB schema. You will be prompted to enter field details for the schema.
42
+
43
+ ```sh
44
+ 4bnode add-mongo-schema User
45
+ ```
46
+
47
+ ### `4bnode add-login`
48
+
49
+ Add a login template to an existing route in your project. You will be prompted to select a route and a model, and then enter the login fields.
50
+
51
+ ```sh
52
+ 4bnode add-login
53
+ ```
54
+
55
+ ### `4bnode add-mongo-insert`
56
+
57
+ Add a template for inserting data into a MongoDB collection. This command allows you to easily create routes for data insertion.
58
+
59
+ ```sh
60
+ 4bnode add-mongo-insert
61
+ ```
62
+
63
+ ### `4bnode add-mongo-update`
64
+
65
+ Add a template for updating data in a MongoDB collection. This facilitates creating routes for updating documents.
66
+
67
+ ```sh
68
+ 4bnode add-mongo-update
69
+ ```
70
+
71
+ ### `4bnode add-mongo-read`
72
+
73
+ Add a template for reading data from a MongoDB collection, helping you to quickly set up read operations.
74
+
75
+ ```sh
76
+ 4bnode add-mongo-read
77
+ ```
78
+
79
+ ### `4bnode add-mongo-delete`
80
+
81
+ Add a template for deleting data from a MongoDB collection, making it easy to handle deletion operations.
82
+
83
+ ```sh
84
+ 4bnode add-mongo-delete
85
+ ```
86
+
87
+ ### `4bnode add-socket`
88
+
89
+ Integrate Socket.io into your project for real-time communication capabilities.
90
+
91
+ ```sh
92
+ 4bnode add-socket
93
+ ```
94
+
95
+ ### `4bnode add-websocket`
96
+
97
+ Add native WebSocket support to your project.
98
+
99
+ ```sh
100
+ 4bnode add-websocket
101
+ ```
102
+
103
+ ### `4bnode add-serialport`
104
+
105
+ Integrate SerialPort functionality into your project. This command does the following:
106
+ - Prompts for Serial Port path and baud rate
107
+ - Automatically updates `.env.development` and `.env.production` with `SERIALPORT_PATH` and `BAUDRATE`
108
+ - Adds SerialPort and Readline parser setup to your `index.js`
109
+ - Installs required dependencies: `serialport` and `@serialport/parser-readline`
110
+
111
+ ```sh
112
+ 4bnode add-serialport
113
+ ```
114
+
115
+ Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.
116
+
117
+ Example incoming data log:
118
+ ```sh
119
+ Received data: <data from serial device>
120
+ ```
121
+
122
+ ## Examples
123
+
124
+ ### Adding MongoDB Schema
125
+
126
+ When you run the command to add a MongoDB schema, you will be prompted to enter the field details.
127
+
128
+ ```sh
129
+ 4bnode add-mongo-schema User
130
+ ```
131
+
132
+ ### Adding a Login Template
133
+
134
+ When you run the command to add a login template, you will be prompted to select a route and a model, and then enter the login fields.
135
+
136
+ ```sh
137
+ 4bnode add-login
138
+ ```
139
+
140
+ ## Real-time Communication Integration
141
+
142
+ ### WebSocket Integration
143
+
144
+ When you add WebSocket integration, it will automatically be added to your project.
145
+
146
+ ```sh
147
+ 4bnode add-websocket
148
+ ```
149
+
150
+ To use `req.wss` in your route endpoints, you can access the WebSocket server as follows:
151
+
152
+ ```js
153
+ router.get("/some-endpoint", (req, res) => {
154
+ req.wss.clients.forEach((client) => {
155
+ if (client.readyState === WebSocket.OPEN) {
156
+ client.send("Hello, client!");
157
+ }
158
+ });
159
+ res.send("Message sent to all WebSocket clients.");
160
+ });
161
+ ```
162
+
163
+ ### Socket.io Integration
164
+
165
+ When you add Socket.io integration, it will automatically be added to your project.
166
+
167
+ ```sh
168
+ 4bnode add-socket
169
+ ```
170
+
171
+ To use `req.io` in your route endpoints, you can access the Socket.io server as follows:
172
+
173
+ ```js
174
+ router.get("/some-endpoint", (req, res) => {
175
+ req.io.emit("message", "Hello, Socket.io clients!");
176
+ res.send("Message sent to all Socket.io clients.");
177
+ });
178
+ ```
179
+
180
+ ## Help
181
+
182
+ If you enter an invalid command, you will see the following message:
183
+
184
+ ```sh
185
+ Unknown command. Use -h or --help for help.
186
+ ```
187
+
188
+ You can also use `-h` or `--help` to get help information.
189
+
190
+ ```sh
191
+ 4bnode -h
192
+ 4bnode --help
193
+ ```
194
+
195
+ ## License
196
+
197
+ This project is licensed under the ISC License.
package/add-login.js CHANGED
File without changes
File without changes
File without changes
package/add-mongo-read.js CHANGED
File without changes
File without changes
package/add-mongo.js CHANGED
File without changes
package/add-socket.js CHANGED
File without changes
package/add-websocket.js CHANGED
File without changes
package/index.js CHANGED
@@ -78,7 +78,7 @@ function checkMongoConfig() {
78
78
  function showHelp() {
79
79
  console.log(
80
80
  chalk.green(`
81
- Usage: ${chalk.bold("4bnode <command> [options]")}
81
+ Usage: ${chalk.bold("node-app <command> [options]")}
82
82
 
83
83
  Commands:
84
84
  ${chalk.blue(
@@ -120,13 +120,13 @@ const param = args[1];
120
120
 
121
121
  if (command === "init") {
122
122
  if (!param) {
123
- console.error(chalk.red("Usage: 4bnode init <projectName>"));
123
+ console.error(chalk.red("Usage: node-app init <projectName>"));
124
124
  process.exit(1);
125
125
  }
126
126
  createSkeletonApp(param);
127
127
  } else if (command === "add-api") {
128
128
  if (!param) {
129
- console.error(chalk.red("Usage: 4bnode add-api <endpointName>"));
129
+ console.error(chalk.red("Usage: node-app add-api <endpointName>"));
130
130
  process.exit(1);
131
131
  }
132
132
  execSync(`node ${path.join(__dirname, "add-api.js")} ${param}`, {
@@ -146,13 +146,13 @@ if (command === "init") {
146
146
  });
147
147
  } else if (command === "add-mongo-schema") {
148
148
  if (!param) {
149
- console.error(chalk.red("Usage: 4bnode add-mongo-schema <schemaName>"));
149
+ console.error(chalk.red("Usage: node-app add-mongo-schema <schemaName>"));
150
150
  process.exit(1);
151
151
  }
152
152
  if (!checkMongoConfig()) {
153
153
  console.error(
154
154
  chalk.red(
155
- "MongoDB is not configured. Please run '4bnode add-mongo' first."
155
+ "MongoDB is not configured. Please run 'node-app add-mongo' first."
156
156
  )
157
157
  );
158
158
  process.exit(1);
package/package.json CHANGED
@@ -1,18 +1,28 @@
1
1
  {
2
2
  "name": "4bnode",
3
- "version": "1.1.1",
4
- "description": "A professional tool to generate a Node.js app by 4Brains Technologies",
3
+ "version": "3.5.2",
4
+ "description": "A CLI tool to generate a Node.js app by 4Brains Technologies",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "4bnode": "index.js"
8
+ "4bnode": "index.js",
9
+ "add-api": "add-api.js",
10
+ "add-mongo": "add-mongo.js",
11
+ "add-socket": "add-socket.js",
12
+ "add-websocket": "add-websocket.js",
13
+ "add-mongo-schema": "add-mongo-schema.js",
14
+ "add-login": "add-login.js",
15
+ "add-mongo-insert": "add-mongo-insert.js",
16
+ "add-mongo-update": "add-mongo-update.js",
17
+ "add-mongo-read": "add-mongo-read.js",
18
+ "add-mongo-delete": "add-mongo-delete.js"
9
19
  },
10
20
  "scripts": {
11
21
  "test": "echo \"Error: no test specified\" && exit 1"
12
22
  },
13
23
  "repository": {
14
24
  "type": "git",
15
- "url": "https://github.com/pawan-4brains/4bnode"
25
+ "url": "https://github.com/pawan-4brains/4brains-node-generator"
16
26
  },
17
27
  "keywords": [
18
28
  "node",
@@ -23,8 +33,8 @@
23
33
  "Node.js skeleton"
24
34
  ],
25
35
  "author": "4Brains",
26
- "license": "Proprietary",
36
+ "license": "ISC",
27
37
  "dependencies": {
28
- "chalk": "^5.4.1"
38
+ "chalk": "^5.3.0"
29
39
  }
30
40
  }
@@ -8,12 +8,12 @@
8
8
  "dev": "nodemon index.js"
9
9
  },
10
10
  "dependencies": {
11
- "express": "^5.1.0",
12
- "dotenv": "^16.5.0",
13
- "body-parser": "^2.2.0",
11
+ "express": "^4.19.2",
12
+ "dotenv": "^16.4.5",
13
+ "body-parser": "^1.20.2",
14
14
  "cors": "^2.8.5"
15
15
  },
16
16
  "devDependencies": {
17
- "nodemon": "^3.1.10"
17
+ "nodemon": "^3.1.3"
18
18
  }
19
19
  }
@@ -8,13 +8,13 @@
8
8
  "dev": "nodemon index.js"
9
9
  },
10
10
  "dependencies": {
11
- "body-parser": "^2.2.0",
11
+ "body-parser": "^1.20.2",
12
12
  "cors": "^2.8.5",
13
- "dotenv": "^16.5.0",
14
- "express": "^5.1.0",
13
+ "dotenv": "^16.4.5",
14
+ "express": "^4.19.2",
15
15
  "ws": "^8.18.2"
16
16
  },
17
17
  "devDependencies": {
18
- "nodemon": "^3.1.10"
18
+ "nodemon": "^3.1.3"
19
19
  }
20
20
  }