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

init-node-project

v1.1.0

Published

complete node project/app/api setup

Downloads

4

Readme

Node.js Project Generator | npx init-node-project

Welcome to the Node.js Project Generator! This tool helps you quickly scaffold a new Node.js application with various optional features like CORS, environment variables, logging, MongoDB integration, and more. 🚀

Table of Contents

Features

  • Project Setup: Quickly sets up a new Node.js project directory with necessary subdirectories.
  • CORS: Option to enable CORS with configurable origins.
  • Environment Variables: Option to use a .env file for environment-specific configurations.
  • Logging: Option to integrate morgan and winston for logging.
  • Response, Error, and Async Handlers: Option to include basic response, error, and async handlers.
  • GitHub Integration: Option to initialize a Git repository with a pre-configured .gitignore and .gitattributes.
  • Prettier: Option to enable Prettier for code formatting.
  • MongoDB: Option to connect a MongoDB database with Mongoose.

Installation

First, ensure you have Node.js and npm installed on your machine. Then, you can install the project generator globally using npm:

Install my-project with npx

  npx init-node-project

Options

  1. Project Name: The name of your project (default: my-node-app).
  2. Enable CORS: Do you want to enable CORS? (default: yes).
  3. Use Environment File: Do you want to use an environment file? (default: yes).
  4. Use Morgan and Winston for Logging: Do you want to use morgan and winston for logging? (default: yes).
  5. Use Basic Response, Error, and Async Handlers: Do you want to use a basic response handler, error handler, and async handler? (default: yes).
  6. Initialize GitHub: Do you want to initialize a GitHub repository? (default: yes).
  7. Enable Prettier: Do you want to enable Prettier? (default: yes).
  8. Connect MongoDB: Do you want to connect a MongoDB database? (default: yes).

Generated Project Structure

The generated project will have the following structure:

my-node-app/
│
├── public/
│   └── temp/
│       └── .gitkeep
│
├── src/
│   ├── config/
│   │   ├── allowedOrigins.js
│   │   └── corsOptions.js
│   ├── controllers/
│   ├── db/
│   │   └── index.js
│   ├── logs/
│   │   └── app.log
│   ├── middlewares/
│   │   └── credentials.js
│   ├── models/
│   ├── routes/
│   ├── tests/
│   ├── utils/
│   │   ├── asyncHandler.js
│   │   ├── ApiResponse.js
│   │   ├── ApiError.js
│   │   └── logger.js
│   ├── app.js
│   └── index.js
│
├── .env
├── .gitattributes
├── .gitignore
├── .prettierrc
├── .prettierignore
├── package.json
└── README.md

Dependencies

Depending on your choices, the generated project may include the following dependencies:

  • express : Fast, unopinionated, minimalist web framework for Node.js.
  • cors : Middleware for enabling CORS.
  • dotenv : Module to load environment variables from a .env file.
  • mongoose : MongoDB object modeling tool.
  • winston : Logger for Node.js.
  • morgan : HTTP request logger middleware for Node.js.

Scripts

The generated package.json will include the following scripts:

  • dev: Start the development server using nodemon.
{
  "scripts": {
    "dev": "nodemon -r dotenv/config --experimental-json-modules src/index.js"
  }
}

License

This project is licensed under the MIT License.