Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/express-unless

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/express-unless

Stub TypeScript definitions entry for express-unless, which provides its own types definitions

  • 2.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
360K
decreased by-14.22%
Maintainers
0
Weekly downloads
 
Created

What is @types/express-unless?

@types/express-unless is a TypeScript type definition package for the express-unless middleware. The express-unless middleware is used to conditionally add middleware to express routes based on certain conditions.

What are @types/express-unless's main functionalities?

Conditional Middleware Application

This feature allows you to conditionally apply middleware to routes. In this example, the middleware is skipped for the '/skip' route.

const express = require('express');
const unless = require('express-unless');
const app = express();

const middleware = (req, res, next) => {
  res.send('Middleware applied');
};

middleware.unless = unless;

app.use(middleware.unless({ path: ['/skip'] }));

app.get('/', (req, res) => res.send('Hello World!'));
app.get('/skip', (req, res) => res.send('Skipped Middleware'));

app.listen(3000, () => console.log('Server running on port 3000'));

Conditional Middleware with Custom Condition

This feature allows you to use a custom condition to determine whether to apply the middleware. In this example, the middleware is skipped if the request contains a specific custom header.

const express = require('express');
const unless = require('express-unless');
const app = express();

const middleware = (req, res, next) => {
  res.send('Middleware applied');
};

middleware.unless = unless;

const customCondition = (req) => req.headers['x-custom-header'] === 'skip';

app.use(middleware.unless(customCondition));

app.get('/', (req, res) => res.send('Hello World!'));

app.listen(3000, () => console.log('Server running on port 3000'));

Other packages similar to @types/express-unless

FAQs

Package last updated on 23 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc