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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aditya3012singh/create-base-backend

v1.1.7

Published

Interactive CLI initializer for production-ready Node.js Express APIs

Readme

create-base-backend

Interactive CLI initializer to instantly scaffold production-ready Node.js Express APIs in either JavaScript or TypeScript, with customizable database and event messaging architectures.


🚀 Usage

You do not need to install the package globally. Simply run the initializer inside your target workspace directory:

npx @aditya3012singh/create-base-backend

The CLI will guide you through interactive choices to customize your template.


🎨 Interactive Prompt Options & Customizations

During scaffolding, the customizer prunes the templates down to only your selected stack, ensuring no unused dependencies or files are left behind:

| Selection | Target File Type | Kept Files | Deleted/Pruned Files | | :--- | :--- | :--- | :--- | | PostgreSQL (Prisma) | .ts / .js | prisma/, src/core/config/db.*, prisma.user.repository.* | mongoose.*, user.model.*, mongoose.user.repository.*, seed.* | | MongoDB (Mongoose) | .ts / .js | src/core/config/db.* (renamed from mongoose.*), mongoose.user.repository.*, seed.* | prisma/ folder, prisma.user.repository.* | | Redis Pub/Sub | .ts / .js | redisEventBus.* | src/core/events/providers/ directory | | RabbitMQ | .ts / .js | providers/rabbitmq.bus.* | providers/kafka.bus.*, redisEventBus.* | | Apache Kafka | .ts / .js | providers/kafka.bus.* | providers/rabbitmq.bus.*, redisEventBus.* |


💾 Database Integration: Mongoose vs. Prisma

A. Working with Mongoose (MongoDB)

If you chose MongoDB + Mongoose, use this pattern to add models and seed:

  1. Write Schema & Model (src/modules/products/models/product.model.ts):
    import mongoose, { Schema, Document } from 'mongoose';
    
    export interface IProduct extends Document {
        name: string;
        price: number;
    }
    
    const ProductSchema = new Schema({
        name: { type: String, required: true },
        price: { type: Number, required: true }
    }, { timestamps: true });
    
    export const ProductModel = mongoose.model<IProduct>('Product', ProductSchema);
  2. Seed Data (src/core/config/seed.ts):
    import { ProductModel } from '../../modules/products/models/product.model.js';
    // Inside seed's main():
    await ProductModel.create({ name: 'Development Server', price: 99.99 });
    Run seed using: npm run db:seed

B. Working with Prisma (PostgreSQL)

If you chose PostgreSQL + Prisma, use this pattern:

  1. Add Model to Schema (prisma/schema.prisma):
    model Product {
      id        String   @id @default(uuid())
      name      String
      price     Float
      createdAt DateTime @default(now())
    }
  2. Apply Migrations:
    npm run db:migrate
  3. Seed Data (prisma/seed.ts):
    // Inside seed's main():
    await prisma.product.create({
        data: { name: 'Development Server', price: 99.99 }
    });
    Run seed using: npm run db:seed

📡 Event Messaging: Redis vs. RabbitMQ vs. Kafka

The application uses dualModeEventBus to abstract the underlying broker. You publish and subscribe identically regardless of your choice.

A. Publishing an Event (Universal Call)

To emit a message from any service or controller:

import dualModeEventBus from '../../core/events/dualModeEventBus.js';

await dualModeEventBus.publish('ORDER_COMPLETED', {
    orderId: 'order_1001',
    amount: 150.00,
    email: '[email protected]'
});

B. Subscribing to an Event (Universal Call)

Register your event listener inside src/core/events/listeners/index.ts so it loads on server boot:

import { IEventBus } from '../eventBus.interface.js';
import logger from '../../logger/structuredLogger.js';

export function registerListeners(eventBus: IEventBus): void {
    eventBus.subscribe('ORDER_COMPLETED', async (payload: any) => {
        logger.info(`📥 [Subscriber] Processing order ${payload.orderId}...`);
        // Add business logic here
    });
}

C. Broker Mechanics under the hood:

  • Redis Pub/Sub: Subscribes to the channel named ORDER_COMPLETED using Node Redis client, fanning out received messages dynamically to registered local callbacks in memory.
  • RabbitMQ: Asserts a dedicated, unique queue named q_ORDER_COMPLETED_<AppName>_<HandlerName> bound to a fanout exchange, ensuring every listener gets its own duplicate copy of the published event (broadcasting pub/sub semantics).
  • Apache Kafka: Subscribes the consumer to a global topic. Incoming events are routed using message keys (e.g. 'ORDER_COMPLETED') to registered handler arrays in memory from a single consume loop, preventing multiple consumer execution crash states.