New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

express-devguard

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-devguard

A plug-and-play middleware suite for small scale APIs: logging + validation + rate-limiting, all in one package.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

express-devguard

Plug-and-play middleware suite for Express.js
Includes API request logging, rate-limiting, and request body validation — perfect for small to mid-scale API projects.

NPM version License Downloads

✨ Features

  • 📈 Pretty logging with optional redaction and file logging
  • 🔐 Request validation with custom schema rules
  • 🚫 Rate limiting based on IP and window

📦 Installation

npm install express-devguard

Quick Start

import express from "express";
import { apiLogger, rateLimiter, validateSchema } from "express-devguard";

const app = express();
app.use(express.json());

// Logger middleware
app.use(
  apiLogger({
    redact: ["password"], // Hides sensitive fields
    logToFile: true, // saves logs to 'requests.log'
  })
);

// Rate limiter
app.use(
  rateLimiter({
    windowMs: 10 * 60 * 1000,
    max: 10,
    message: "Too much requests detected!!",
  })
);

// Schema validation
const schema = {
  username: {
    required: true,
    type: "string" as const,
    minLength: 3,
  },
  password: {
    required: true,
    type: "string" as const,
    minLength: 8,
  },
};

app.post("/login", validateSchema(schema), (req, res) => {
  res.send({ message: "Logged in" });
});

app.listen(3000, () => {
  console.log("Server running at http://localhost:3000");
});

⚙️ API Reference

apiLogger(options)

OptionTypeDescription
redactstring[]Keys to hide in request body logs
logToFilebooleanWhether to save logs to a file
logFilePathstringCustom log file path (default: requests.log)

rateLimiter(options)

OptionTypeDescription
windowMsnumberTime window in milliseconds
maxnumberMax number of requests per IP per window
messagestringResponse message when rate limit is hit

validateSchema(schema)

Validates incoming req.body using custom rules.

Rule options per field:

RuleTypeDescription
requiredbooleanWhether the field is required
type"string" | "number" | "boolean"Expected type of the value
minLengthnumberMinimum string length
maxLengthnumberMaximum string length
minnumberMinimum numeric value
maxnumberMaximum numeric value

License

MIT

Keywords

express

FAQs

Package last updated on 23 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts