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-nest-template-malahimdev

v1.0.7

Published

Scaffolds a NestJS template with Swagger, global pipes, exception filters, MongoDB connection and response helpers.

Downloads

61

Readme

create-nest-template-malahimdev 🚀

Scaffolds a NestJS backend template with built-in best practices and sensible defaults.

Includes:

  • Swagger (light /docs and dark /docsdark) with Bearer auth support
  • Global validation pipes (whitelist, transform, forbidNonWhitelisted)
  • Global exception handling with standardized response helpers
  • MongoDB connection boilerplate
  • Example public / protected / hidden endpoints and a DTO-based POST

Features

  • Quick project scaffold for NestJS backends
  • Ready-to-use helpers for success and error responses
  • Swagger UI with light/dark themes and Bearer token configured
  • Example JwtAuthGuard usage for protected routes
  • Hidden endpoints excluded from Swagger using @ApiExcludeEndpoint()

Installation (recommended)

Use npx to scaffold a new project:

npx create-nest-template-malahimdev my-new-backend
# or (force latest)
npx -y create-nest-template-malahimdev@latest my-new-backend

Getting started

  1. Move into your project folder:
cd my-new-backend
  1. Install dependencies:
npm install
  1. Create a .env file in the project root and add these variables (example):
# .env
PORT=3000
MONGO_URI=mongodb://localhost:27017/mydb
# optional: used by JWT guard if included
JWT_SECRET=your_jwt_secret_here
  • PORT → defaults to 3000 if not set
  • MONGO_URI → defaults to local MongoDB instance if not set
  1. Run the app in development mode:
npm run start:dev

Common npm scripts included in the template (example):

{
  "scripts": {
    "start": "nest start",
    "start:dev": "nest start --watch",
    "build": "nest build"
  }
}

API Endpoints (examples)

| Method | Endpoint | Description | Auth | Swagger Visible | | ------ | ---------------: | --------------------------------------- | :--: | :-------------: | | GET | / | Health check / root | ❌ | ✅ | | GET | /public-api | Example public API | ❌ | ✅ | | GET | /protected-api | Example protected API (JWT required) | ✅ | ✅ | | GET | /hidden-api | Hidden endpoint (excluded from Swagger) | ❌ | 🚫 | | POST | /create-item | Example POST with DTO validation | ❌ | ✅ |


Swagger docs

  • Light theme → http://localhost:3000/docs
  • Dark theme → http://localhost:3000/docsdark

Both include Bearer token configuration so you can paste a JWT and test protected endpoints.


Response helpers

Success response helper usage:

successResponse('Message here', { data: { /* payload */ } });

Error responses (these throw appropriate Nest exceptions):

errorResponse.badRequest(['Invalid input']);
errorResponse.unauthorized(['You must login first']);
errorResponse.internal();

errorResponse produces standardized error objects and throws the correct HTTP exception.


How routes are organized (example)

The template ships with a simple example controller that demonstrates:

  • a public route
  • a protected route guarded with JwtAuthGuard and annotated with @ApiBearerAuth()
  • a hidden route annotated with @ApiExcludeEndpoint()
  • a POST endpoint using DTO validation

This is a good starting point — replace or extend controllers, modules, and guards as your app grows.


Should I include auth in the template?

This template includes a ready-to-wire JwtAuthGuard and Swagger Bearer setup. The guard itself can be disabled or removed if you prefer a minimal scaffold. Including an auth guard is helpful for developers who want a secure template out of the box; you can keep it optional by documenting how to enable/replace it (e.g. wire your own auth service and set JWT_SECRET).


Contributing

Feel free to open an issue or submit a PR to add improvements (scripts, CI, more templates, extra integrations).


Author

Malahim Haseeb 📧 [email protected] 🌐 malahim.dev


License

MIT © 2025 Malahim Haseeb