npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

4brains-node-generator

v3.4.8

Published

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

Downloads

825

Readme

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

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.