Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@types/express-unless
Advanced tools
TypeScript definitions for 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.
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'));
express-conditional-middleware is a package that allows you to conditionally apply middleware to routes based on custom conditions. It is similar to express-unless but provides a more flexible API for defining conditions.
npm install --save @types/express-unless
This package contains type definitions for express-unless ( https://www.npmjs.org/package/express-unless ).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-unless
Additional Details
These definitions were written by Wonshik Kim https://github.com/wokim, Joao Vieira https://github.com/joaovieira, Michal Kaminski https://github.com/michal-b-kaminski.
FAQs
Stub TypeScript definitions entry for express-unless, which provides its own types definitions
The npm package @types/express-unless receives a total of 290,410 weekly downloads. As such, @types/express-unless popularity was classified as popular.
We found that @types/express-unless demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.