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 🙏

© 2025 – Pkg Stats / Ryan Hefner

create-node-dev

v1.1.0

Published

CLI tool to generate a professional Node.js backend with Express and MongoDB/PostgreSQL

Downloads

11

Readme

Create Node Backend

A CLI tool to generate a professional Node.js backend with Express, supporting MongoDB or PostgreSQL, with a pre-configured folder structure, CORS, dotenv, authentication, and optional logging.

Installation

Install the package globally to use the CLI command:

npx create-node-dev

The CLI will prompt you for the following:

  • Project name: The name of the project folder (default: node-backend).
  • Use src folder: Whether to organize code in a src folder (y/N).
  • Main file name: The main server file (default: index.js).
  • Database: Choose between MongoDB or PostgreSQL (default: MongoDB).
  • Include logging (winston): Whether to include logging with winston (y/N).

Environment Variables

The .env file includes:

# Server Configuration
NODE_ENV=development
PORT=3000

# JWT Secret
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production

# Logging (if enabled)
LOG_LEVEL=info

# Database Configuration (example for MongoDB)
MONGODB_URI=mongodb://localhost:27017/your-project-name

# OR (example for PostgreSQL)
DB_NAME=your-project-name
DB_USER=postgres
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432

Update these with your actual database credentials.

Scripts

  • npm start: Run the server in production mode.
  • npm run dev: Run the server with nodemon for development.
  • npm test: Run tests with jest.
  • npm run lint: Lint code with eslint.
  • npm run format: Format code with prettier.

API Documentation

Base URL: http://localhost:3000/api

Authentication: Most endpoints require a JWT token in the Authorization header: Bearer <token>.

Authentication Endpoints

POST /auth/register

Register a new user.

Body:

{
  "name": "string",
  "email": "string",
  "password": "string"
}

Responses:

  • 201: { success: true, message: "User registered successfully", token: "string", user: { id, name, email } }
  • 400: { success: false, message: "string" }
  • 500: { success: false, message: "Server error" }

POST /auth/login

Log in a user.

Body:

{
  "email": "string",
  "password": "string"
}

Responses:

  • 200: { success: true, message: "Login successful", token: "string", user: { id, name, email } }
  • 400: { success: false, message: "Invalid credentials" }
  • 500: { success: false, message: "Server error" }

GET /auth/profile

Get authenticated user's profile.

Headers: Authorization: Bearer <token>

Responses:

  • 200: { success: true, user: { id, name, email } }
  • 401: { success: false, message: "No token, authorization denied" }
  • 404: { success: false, message: "User not found" }
  • 500: { success: false, message: "Server error" }

User Management Endpoints

GET /users

List all users.

Headers: Authorization: Bearer <token>

Responses:

  • 200: { success: true, count: number, data: [{ id, name, email, role, isActive, createdAt, updatedAt }] }
  • 401: { success: false, message: "No token, authorization denied" }
  • 500: { success: false, message: "Server error" }

GET /users/:id

Get a user by ID.

Headers: Authorization: Bearer <token>

Responses:

  • 200: { success: true, data: { id, name, email, role, isActive, createdAt, updatedAt } }
  • 401: { success: false, message: "No token, authorization denied" }
  • 404: { success: false, message: "User not found" }
  • 500: { success: false, message: "Server error" }

PUT /users/:id

Update a user.

Headers: Authorization: Bearer <token>

Body:

{
  "name": "string",
  "email": "string",
  "role": "string"
}

Responses:

  • 200: { success: true, message: "User updated successfully", data: { id, name, email, role, isActive, updatedAt } }
  • 401: { success: false, message: "No token, authorization denied" }
  • 404: { success: false, message: "User not found" }
  • 500: { success: false, message: "Server error" }

DELETE /users/:id

Delete a user.

Headers: Authorization: Bearer <token>

Responses:

  • 200: { success: true, message: "User deleted successfully" }
  • 401: { success: false, message: "No token, authorization denied" }
  • 404: { success: false, message: "User not found" }
  • 500: { success: false, message: "Server error" }

License

MIT