Catalog npm
Back to packageRELEASE DETAILS

2.2.8

npm

4brains-node-generator

A CLI tool to generate a Node.js app by 4Brains Technologies

expressexpress-generatorgeneratornodenode.jsnode.js skeletonnode generator, express, express generator, node.js
Published20 Jun 2024
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

4Brains Node Generator

A comprehensive CLI tool to streamline the generation and management of Node.js applications by 4Brains Technologies.

Installation

To install the 4Brains Node Generator globally, use the following command:

npm install -g 4brains-node-generator

Available Commands

node-app init <projectName>

Initialize a new Node.js project with the specified name.

node-app init my-project

node-app add-api <endpointName>

Add a new API endpoint to your project.

node-app add-api users

node-app add-mongo

Integrate MongoDB into your project. This command sets up the necessary MongoDB configuration.

node-app add-mongo

node-app add-mongo-schema <schemaName>

Create a new MongoDB schema. You will be prompted to enter field details for the schema.

node-app add-mongo-schema User

node-app add-login

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.

node-app add-login

node-app add-mongo-insert

Add a template for inserting data into a MongoDB collection. This command allows you to easily create routes for data insertion.

node-app add-mongo-insert

node-app add-mongo-update

Add a template for updating data in a MongoDB collection. This facilitates creating routes for updating documents.

node-app add-mongo-update

node-app add-mongo-read

Add a template for reading data from a MongoDB collection, helping you to quickly set up read operations.

node-app add-mongo-read

node-app add-mongo-delete

Add a template for deleting data from a MongoDB collection, making it easy to handle deletion operations.

node-app add-mongo-delete

node-app add-socket

Integrate Socket.io into your project for real-time communication capabilities.

node-app add-socket

node-app add-websocket

Add native WebSocket support to your project.

node-app add-websocket

node-app add-serialport

Integrate SerialPort functionality into your project. This command does the following:

  • Prompts for Serial Port path and baud rate
  • Automatically updates .env.development and .env.production with SERIALPORT_PATH and BAUDRATE
  • Adds SerialPort and Readline parser setup to your index.js
  • Installs required dependencies: serialport and @serialport/parser-readline
node-app add-serialport

Once added, your project will automatically initialize the serial port with the specified configuration and log incoming data.

Example incoming data log:

Received data: <data from serial device>

Examples

Adding MongoDB Schema

When you run the command to add a MongoDB schema, you will be prompted to enter the field details.

node-app add-mongo-schema User

Adding a Login Template

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.

node-app add-login

Real-time Communication Integration

WebSocket Integration

When you add WebSocket integration, it will automatically be added to your project.

node-app add-websocket

To use req.wss in your route endpoints, you can access the WebSocket server as follows:

router.get("/some-endpoint", (req, res) => {
  req.wss.clients.forEach((client) => {
    if (client.readyState === WebSocket.OPEN) {
      client.send("Hello, client!");
    }
  });
  res.send("Message sent to all WebSocket clients.");
});

Socket.io Integration

When you add Socket.io integration, it will automatically be added to your project.

node-app add-socket

To use req.io in your route endpoints, you can access the Socket.io server as follows:

router.get("/some-endpoint", (req, res) => {
  req.io.emit("message", "Hello, Socket.io clients!");
  res.send("Message sent to all Socket.io clients.");
});

Help

If you enter an invalid command, you will see the following message:

Unknown command. Use -h or --help for help.

You can also use -h or --help to get help information.

node-app -h
node-app --help

License

This project is licensed under the ISC License.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "d99fb042cce826818b706252aa1a966f9b9ccc73",
  "tarball": "https://registry.npmjs.org/4brains-node-generator/-/4brains-node-generator-2.2.8.tgz",
  "fileCount": 16,
  "integrity": "sha512-hBPNzFRmUUdytuj8nRYEV/EdpwPiHTjBnBUk6c2k0niuIhce50VThpZNXdLqqW1lDYl6SkYgywPNAtvTJJljGw==",
  "signatures": [
    {
      "sig": "MEUCIQDYufSbeMNJfAmPkFpLMgDrL0T9WOaJzjUp/d89WfCCUwIgC0H446FoMJytiE1KIglP2VkkSWPmLM4oj/9yTDl+6gM=",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 42294
}

Repository

PENDING
pawan-4brains/4brains-node-generator

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:05 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:b329bfeccf5ce3e081205c95bbb3b96c3d09a464a3fa86cdc83fcfdcefc72363

Other collected versions

3.5.112 Jun3.5.012 Jun3.4.722 Jul3.4.622 Jul3.4.522 Jul3.4.322 JulView all collected versions →