4bnode 1.0.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.
package/README.md ADDED
@@ -0,0 +1,199 @@
1
+ # 4Brains Node CLI
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 CLI globally, use the following command:
8
+
9
+ ```sh
10
+ npm install -g 4bnode
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
+
107
+ - Prompts for Serial Port path and baud rate
108
+ - Automatically updates `.env.development` and `.env.production` with `SERIALPORT_PATH` and `BAUDRATE`
109
+ - Adds SerialPort and Readline parser setup to your `index.js`
110
+ - Installs required dependencies: `serialport` and `@serialport/parser-readline`
111
+
112
+ ```sh
113
+ 4bnode add-serialport
114
+ ```
115
+
116
+ Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.
117
+
118
+ Example incoming data log:
119
+
120
+ ```sh
121
+ Received data: <data from serial device>
122
+ ```
123
+
124
+ ## Examples
125
+
126
+ ### Adding MongoDB Schema
127
+
128
+ When you run the command to add a MongoDB schema, you will be prompted to enter the field details.
129
+
130
+ ```sh
131
+ 4bnode add-mongo-schema User
132
+ ```
133
+
134
+ ### Adding a Login Template
135
+
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.
137
+
138
+ ```sh
139
+ 4bnode add-login
140
+ ```
141
+
142
+ ## Real-time Communication Integration
143
+
144
+ ### WebSocket Integration
145
+
146
+ When you add WebSocket integration, it will automatically be added to your project.
147
+
148
+ ```sh
149
+ 4bnode add-websocket
150
+ ```
151
+
152
+ To use `req.wss` in your route endpoints, you can access the WebSocket server as follows:
153
+
154
+ ```js
155
+ router.get("/some-endpoint", (req, res) => {
156
+ req.wss.clients.forEach((client) => {
157
+ if (client.readyState === WebSocket.OPEN) {
158
+ client.send("Hello, client!");
159
+ }
160
+ });
161
+ res.send("Message sent to all WebSocket clients.");
162
+ });
163
+ ```
164
+
165
+ ### Socket.io Integration
166
+
167
+ When you add Socket.io integration, it will automatically be added to your project.
168
+
169
+ ```sh
170
+ 4bnode add-socket
171
+ ```
172
+
173
+ To use `req.io` in your route endpoints, you can access the Socket.io server as follows:
174
+
175
+ ```js
176
+ router.get("/some-endpoint", (req, res) => {
177
+ req.io.emit("message", "Hello, Socket.io clients!");
178
+ res.send("Message sent to all Socket.io clients.");
179
+ });
180
+ ```
181
+
182
+ ## Help
183
+
184
+ If you enter an invalid command, you will see the following message:
185
+
186
+ ```sh
187
+ Unknown command. Use -h or --help for help.
188
+ ```
189
+
190
+ You can also use `-h` or `--help` to get help information.
191
+
192
+ ```sh
193
+ 4bnode -h
194
+ 4bnode --help
195
+ ```
196
+
197
+ ## License
198
+
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.
@@ -0,0 +1,199 @@
1
+ # 4Brains Node CLI
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 CLI globally, use the following command:
8
+
9
+ ```sh
10
+ npm install -g 4bnode
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
+
107
+ - Prompts for Serial Port path and baud rate
108
+ - Automatically updates `.env.development` and `.env.production` with `SERIALPORT_PATH` and `BAUDRATE`
109
+ - Adds SerialPort and Readline parser setup to your `index.js`
110
+ - Installs required dependencies: `serialport` and `@serialport/parser-readline`
111
+
112
+ ```sh
113
+ 4bnode add-serialport
114
+ ```
115
+
116
+ Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.
117
+
118
+ Example incoming data log:
119
+
120
+ ```sh
121
+ Received data: <data from serial device>
122
+ ```
123
+
124
+ ## Examples
125
+
126
+ ### Adding MongoDB Schema
127
+
128
+ When you run the command to add a MongoDB schema, you will be prompted to enter the field details.
129
+
130
+ ```sh
131
+ 4bnode add-mongo-schema User
132
+ ```
133
+
134
+ ### Adding a Login Template
135
+
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.
137
+
138
+ ```sh
139
+ 4bnode add-login
140
+ ```
141
+
142
+ ## Real-time Communication Integration
143
+
144
+ ### WebSocket Integration
145
+
146
+ When you add WebSocket integration, it will automatically be added to your project.
147
+
148
+ ```sh
149
+ 4bnode add-websocket
150
+ ```
151
+
152
+ To use `req.wss` in your route endpoints, you can access the WebSocket server as follows:
153
+
154
+ ```js
155
+ router.get("/some-endpoint", (req, res) => {
156
+ req.wss.clients.forEach((client) => {
157
+ if (client.readyState === WebSocket.OPEN) {
158
+ client.send("Hello, client!");
159
+ }
160
+ });
161
+ res.send("Message sent to all WebSocket clients.");
162
+ });
163
+ ```
164
+
165
+ ### Socket.io Integration
166
+
167
+ When you add Socket.io integration, it will automatically be added to your project.
168
+
169
+ ```sh
170
+ 4bnode add-socket
171
+ ```
172
+
173
+ To use `req.io` in your route endpoints, you can access the Socket.io server as follows:
174
+
175
+ ```js
176
+ router.get("/some-endpoint", (req, res) => {
177
+ req.io.emit("message", "Hello, Socket.io clients!");
178
+ res.send("Message sent to all Socket.io clients.");
179
+ });
180
+ ```
181
+
182
+ ## Help
183
+
184
+ If you enter an invalid command, you will see the following message:
185
+
186
+ ```sh
187
+ Unknown command. Use -h or --help for help.
188
+ ```
189
+
190
+ You can also use `-h` or `--help` to get help information.
191
+
192
+ ```sh
193
+ 4bnode -h
194
+ 4bnode --help
195
+ ```
196
+
197
+ ## License
198
+
199
+ This project is licensed under the ISC License.