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

create-ment-api

v1.1.0

Published

Create Express TypeScript API with MENT template

Readme

Create MENT API

A modern Express.js + TypeScript API template generator with built-in utilities and best practices.

Features

  • Express 5 - Latest Express.js framework
  • 🔷 TypeScript - Full TypeScript support with type definitions
  • Validation - Request validation with express-validator
  • 🗄️ MongoDB - Mongoose ODM integration
  • 📧 Email - Nodemailer for sending emails
  • 🛠️ Development Tools - Nodemon and ts-node for hot reloading
  • 📝 Logging - Morgan HTTP request logger
  • ⚠️ Error Handling - Custom error middleware and utilities
  • 🔧 API Utilities - Built-in pagination, filtering, and searching

Quick Start

Create a new project

npm create ment-api my-api
cd my-api
npm run dev

Create in current directory

npm create ment-api .

What's Included

Project Structure

my-api/
├── src/
│   ├── app.ts                      # Express app configuration
│   ├── server.ts                   # Server entry point
│   ├── conf/
│   │   └── conf.ts                 # Configuration management
│   ├── middlewares/
│   │   └── error.middlewares.ts    # Error handling middleware
│   ├── service/
│   │   └── email.service.ts        # Email service
│   ├── utils/
│   │   ├── ApiAggregateFeatures.ts # MongoDB aggregation utilities
│   │   ├── ApiError.ts             # Custom error class
│   │   ├── ApiFeatures.ts          # Query features (filter, sort, paginate)
│   │   ├── ApiResponse.ts          # Standardized response format
│   │   ├── AsyncHandler.ts         # Async error handling wrapper
│   │   └── commonUtils.ts          # Common utility functions
│   └── validators/
│       ├── mongodb.validator.ts    # MongoDB validation utilities
│       └── validate.ts             # Validation middleware
├── public/                         # Static files
├── tsconfig.json                   # TypeScript configuration
└── package.json                    # Dependencies

Dependencies

Production:

  • express - Web framework
  • dotenv - Environment variable management
  • mongoose - MongoDB ODM
  • express-validator - Request validation
  • nodemailer - Email sending

Development:

  • typescript - TypeScript compiler
  • ts-node - TypeScript execution
  • nodemon - Auto-restart on file changes
  • morgan - HTTP request logger
  • Type definitions for all dependencies

Available Scripts

npm run dev    # Start development server with auto-reload

Usage Examples

Using API Response Utility

import { ApiResponse } from "./utils/ApiResponse";

res.status(200).json(new ApiResponse(200, data, "Success message"));

Using Async Handler (omits try catch boock)

import { asyncHandler } from "./utils/AsyncHandler";

export const getUsers = asyncHandler(async (req, res, next) => {
  const users = await User.find();
  res.json(new ApiResponse(200, users, "Users fetched"));
});

Using API Features (Pagination, Filtering, Sorting)

import { ApiFeatures } from "./utils/ApiFeatures";

const features = new ApiFeatures(User.find(), req.query)
  .filter()
  .sort()
  .limitFields()
  .paginate();

const users = await features.query;

Using Api Aggregated Features (Pagination, Filtering, Sorting)

import { ApiAggregatedFeatures } from "./utils/ApiAggregatedFeatures";

const features = new ApiAggregatedFeatures(
  User.aggregate([
    {
      $match: {
        $id: "user_id_value",
      },
    },
  ]),
  req.query,
)
  .filter()
  .sort()
  .limitFields()
  .paginate();

const users = await features.aggregation;

Custom Error Handling

import { ApiError } from "./utils/ApiError";

throw new ApiError(400, "Invalid request parameters");

// -- or --

return next(
  new ApiError(400, "Error Custom Message", { error: "null or data" }),
);

Environment Variables

Create a .env file in your project root:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/myapp

# Email configuration (nodemailer + gmail)
[email protected]
EMAIL_PASSWORD=your-app-password

Requirements

  • Node.js 16 or higher
  • npm or yarn

Why MENT API?

  • 🚀 Production Ready - Built with best practices
  • 📦 Always Latest - Installs the newest versions of all packages
  • 🎯 Opinionated - Pre-configured structure to get started quickly
  • 🔧 Flexible - Easy to customize and extend
  • 📚 Well Organized - Clear separation of concerns

Author

Nikesh Adhikari

License

ISC

Contributing

Issues and pull requests are welcome!

Repository

https://github.com/nikeshad574/ment-api


Happy Coding! 🎉