4bnode 1.0.5 → 1.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.
Files changed (2) hide show
  1. package/README.md +89 -23
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -26,70 +26,116 @@ npx 4bnode add-serialport
26
26
 
27
27
  Initialize a new Node.js project with the specified name.
28
28
 
29
+ ```sh
30
+ npx 4bnode init my-project
31
+ ```
32
+
29
33
  ### `npx 4bnode add-api <endpointName>`
30
34
 
31
35
  Add a new API endpoint to your project.
32
36
 
37
+ ```sh
38
+ npx 4bnode add-api users
39
+ ```
40
+
33
41
  ### `npx 4bnode add-mongo`
34
42
 
35
43
  Integrate MongoDB into your project. This command sets up the necessary MongoDB configuration.
36
44
 
45
+ ```sh
46
+ npx 4bnode add-mongo
47
+ ```
48
+
37
49
  ### `npx 4bnode add-mongo-schema <schemaName>`
38
50
 
39
51
  Create a new MongoDB schema. You will be prompted to enter field details for the schema.
40
52
 
53
+ ```sh
54
+ npx 4bnode add-mongo-schema User
55
+ ```
56
+
41
57
  ### `npx 4bnode add-login`
42
58
 
43
- Add a login template to an existing route in your project.
59
+ 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
+
61
+ ```sh
62
+ npx 4bnode add-login
63
+ ```
44
64
 
45
65
  ### `npx 4bnode add-mongo-insert`
46
66
 
47
- Add a route for inserting data into a MongoDB collection.
67
+ Add a template for inserting data into a MongoDB collection. This command allows you to easily create routes for data insertion.
68
+
69
+ ```sh
70
+ npx 4bnode add-mongo-insert
71
+ ```
48
72
 
49
73
  ### `npx 4bnode add-mongo-update`
50
74
 
51
- Add a route for updating data in a MongoDB collection.
75
+ Add a template for updating data in a MongoDB collection. This facilitates creating routes for updating documents.
76
+
77
+ ```sh
78
+ npx 4bnode add-mongo-update
79
+ ```
52
80
 
53
81
  ### `npx 4bnode add-mongo-read`
54
82
 
55
- Add a route for reading data from a MongoDB collection.
83
+ Add a template for reading data from a MongoDB collection, helping you to quickly set up read operations.
84
+
85
+ ```sh
86
+ npx 4bnode add-mongo-read
87
+ ```
56
88
 
57
89
  ### `npx 4bnode add-mongo-delete`
58
90
 
59
- Add a route for deleting data from a MongoDB collection.
91
+ Add a template for deleting data from a MongoDB collection, making it easy to handle deletion operations.
92
+
93
+ ```sh
94
+ npx 4bnode add-mongo-delete
95
+ ```
60
96
 
61
97
  ### `npx 4bnode add-socket`
62
98
 
63
- Integrate Socket.io into your project for real-time communication.
99
+ Integrate Socket.io into your project for real-time communication capabilities.
100
+
101
+ ```sh
102
+ npx 4bnode add-socket
103
+ ```
64
104
 
65
105
  ### `npx 4bnode add-websocket`
66
106
 
67
107
  Add native WebSocket support to your project.
68
108
 
109
+ ```sh
110
+ npx 4bnode add-websocket
111
+ ```
112
+
69
113
  ### `npx 4bnode add-serialport`
70
114
 
71
- Integrate SerialPort functionality into your project. This command:
115
+ Integrate SerialPort functionality into your project. This command does the following:
72
116
 
73
117
  - Prompts for Serial Port path and baud rate
74
- - Updates `.env.development` and `.env.production`
75
- - Injects SerialPort setup code into your `index.js`
76
- - Installs required packages
77
-
78
- Once added, incoming data will be logged like:
118
+ - Automatically updates `.env.development` and `.env.production` with `SERIALPORT_PATH` and `BAUDRATE`
119
+ - Adds SerialPort and Readline parser setup to your `index.js`
120
+ - Installs required dependencies: `serialport` and `@serialport/parser-readline`
79
121
 
80
122
  ```sh
81
- Received data: <data from serial device>
123
+ npx 4bnode add-serialport
82
124
  ```
83
125
 
84
- ## Examples
126
+ Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.
85
127
 
86
- ### Creating a New Project
128
+ Example incoming data log:
87
129
 
88
130
  ```sh
89
- npx 4bnode init my-app
131
+ Received data: <data from serial device>
90
132
  ```
91
133
 
92
- ### Adding a MongoDB Schema
134
+ ## Examples
135
+
136
+ ### Adding MongoDB Schema
137
+
138
+ When you run the command to add a MongoDB schema, you will be prompted to enter the field details.
93
139
 
94
140
  ```sh
95
141
  npx 4bnode add-mongo-schema User
@@ -97,19 +143,23 @@ npx 4bnode add-mongo-schema User
97
143
 
98
144
  ### Adding a Login Template
99
145
 
146
+ 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
+
100
148
  ```sh
101
149
  npx 4bnode add-login
102
150
  ```
103
151
 
104
- ### Integrating SerialPort
152
+ ## Real-time Communication Integration
153
+
154
+ ### WebSocket Integration
155
+
156
+ When you add WebSocket integration, it will automatically be added to your project.
105
157
 
106
158
  ```sh
107
- npx 4bnode add-serialport
159
+ npx 4bnode add-websocket
108
160
  ```
109
161
 
110
- ## Real-time Communication Integration
111
-
112
- ### WebSocket
162
+ To use `req.wss` in your route endpoints, you can access the WebSocket server as follows:
113
163
 
114
164
  ```js
115
165
  router.get("/some-endpoint", (req, res) => {
@@ -122,7 +172,15 @@ router.get("/some-endpoint", (req, res) => {
122
172
  });
123
173
  ```
124
174
 
125
- ### Socket.io
175
+ ### Socket.io Integration
176
+
177
+ When you add Socket.io integration, it will automatically be added to your project.
178
+
179
+ ```sh
180
+ npx 4bnode add-socket
181
+ ```
182
+
183
+ To use `req.io` in your route endpoints, you can access the Socket.io server as follows:
126
184
 
127
185
  ```js
128
186
  router.get("/some-endpoint", (req, res) => {
@@ -133,6 +191,14 @@ router.get("/some-endpoint", (req, res) => {
133
191
 
134
192
  ## Help
135
193
 
194
+ If you enter an invalid command, you will see the following message:
195
+
196
+ ```sh
197
+ Unknown command. Use -h or --help for help.
198
+ ```
199
+
200
+ You can also use `-h` or `--help` to get help information.
201
+
136
202
  ```sh
137
203
  npx 4bnode -h
138
204
  npx 4bnode --help
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4bnode",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A professional tool to generate a Node.js app by 4Brains Technologies",
5
5
  "main": "index.js",
6
6
  "type": "module",