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

monpress

v1.0.3

Published

An intuitive Express framework in TypeScript that leverages file-based routing and flexible middleware support to streamline backend development.

Downloads

158

Readme


Monpress

Welcome to the Monpress! This tool helps you create and manage Express-based Monpress projects with:

  • ✅ File-based routing
  • ✅ Built-in REST method handlers
  • ✅ Global middleware support
  • ✅ Fast and flexible development experience

📦 Installation

Make sure you have Node.js installed.

Install Monpress globally via npm:

npm install -g monpress

🚀 Usage

The Monpress includes several commands to streamline your workflow:

🔧 Create a New Project

monpress create

You'll be prompted to:

  • Enter a project name
  • Choose a package manager (npm, yarn, or pnpm)

🧑‍💻 Start the Development Server

monpress dev

Launches your Monpress project in development mode with file-watching enabled.


🛠️ Generate Routes

monpress generate

Automatically generates route mappings from your file structure.


📁 File-Based Routing

Monpress uses the routes/ directory to define routes via filenames. This system is inspired by modern frameworks like Next.js and SvelteKit.

🧭 Route Mapping Example

| File Path | Route Path | | ----------------------- | ------------- | | routes/index.ts | / | | routes/about.ts | /about | | routes/contact.ts | /contact | | routes/blog.ts | /blog | | routes/blog/[blog].ts | /blog/:blog | | routes/user/[id_].ts | /user/:id? |

  • [] denotes dynamic segments
  • [_] (trailing underscore) denotes optional segments

🧩 Route File Example (routes/index.ts)

import { httpRequest } from "monpress";

export const GET = httpRequest(async (req, res) => {
  res.json({ message: "GET request successful" });
});

export const POST = httpRequest(async (req, res) => {
  res.json({ message: "POST request successful" });
});

export const PATCH = httpRequest(async (req, res) => {
  res.json({ message: "PATCH request successful" });
});

export const PUT = httpRequest(async (req, res) => {
  res.json({ message: "PUT request successful" });
});

export const DELETE = httpRequest(async (req, res) => {
  res.json({ message: "DELETE request successful" });
});

You can export any HTTP method handler (GET, POST, etc.) as needed.


🧱 Middleware

Monpress supports global middleware using the middleware() helper. Useful for:

  • Authentication
  • Logging
  • Custom headers
  • Request preprocessing

📌 Creating Middleware

import { middleware } from "monpress";

export const authMiddleware = middleware((req, res, next) => {
  if (req.path.startsWith("/auth")) {
    req.user = {
      id: "1",
      name: "Sourav",
    };
  }
  next();
});

🔗 Registering Middleware

Add middleware when initializing your Monpress app:

import { MonPress } from "monpress";
import { authMiddleware } from "./middlewares/auth";
import routes from "./routes";

const mon = MonPress({
  routes,
  middleware: [authMiddleware],
  express(app, http) {
    // Optional: custom Express logic here
  },
});

✅ All registered middleware is executed before your route handlers.


📁 File Uploading with Multer

Monpress supports file uploading using the popular multer middleware. Here's how you can integrate it into your Monpress application:

📦 Installation

First, install multer:

npm install multer

⚙️ Configuration

Create a file, for example, routes/upload.ts, to handle file uploads. Here's an example of how to configure multer and create a route:

import { httpRequest } from "monpress";
import multer from "multer";
import path from "path";

// Configure storage for uploaded files
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, "uploads/"); // Folder to store uploaded files
  },
  filename: function (req, file, cb) {
    const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
    cb(null, uniqueSuffix + path.extname(file.originalname)); // e.g., 1624567890-123456789.jpg
  },
});

// Create the multer upload instance
const upload = multer({ storage: storage });

// Example POST request handler with file upload
export const POST = httpRequest(async (req, res) => {
  upload.any()(req, res, async (err: any) => {
    if (err) {
      return res.status(500).json({ message: "Error uploading file" });
    }
    // Files are available in req.files, and other form data in req.body
    res.json({ files: req.files, body: req.body });
  });
});

📍 Route Definition

In this example, the POST route uses upload.any() to handle any number of files. You can also use upload.single('fieldName') to handle a single file or upload.array('fieldName', maxCount) to handle a specific number of files.

🧪 Testing the Upload

You can test this endpoint using curl:

curl -X POST -F "file=@/path/to/your/file.jpg" http://localhost:3000/upload

Make sure to replace /path/to/your/file.jpg with the actual path to your file.


🔄 Example Workflow

# Create a new project
monpress create

# Move into the project directory
cd my-project

# Start the dev server
monpress dev

# Generate route files
monpress generate

🛠 Commands

| Command | Description | | ------------------- | ---------------------------------- | | monpress create | Create a new Monpress project | | monpress dev | Start the development server | | monpress generate | Generate route mappings from files | | monpress --help | Show help and usage info |


🤝 Contributing

Want to contribute? Here's how:

  1. Fork the repo
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

📄 License

Licensed under the MIT License.


Happy coding with Monpress! ⚡
File-based routing meets Express power.