
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Express middlewares for validating incoming data with type inference
😧 Afraid?! You don't need to be: Incoming data of your express route is validated! Type inference included!
npm install afraid --save --no-optional
import {query, f, fail} from 'afraid';
import * as express from 'express';
const app = express();
app.get('/users', [
query(
f('limit').int(),
f('offset').int(),
f('filters').string().array().opt(),
),
fail,
], (req, res, next) => {
// ...
});
Omitting --no-optional
will install required packages class-transformer
and reflect-metadata
automatically
npm install afraid --save
The following flags in tsconfig.json
:
{
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
import {query, Field, IsInt, fail} from 'afraid'
import * as express from 'express';
const app = express();
class UserDTO {
@Field name: string;
@IsInt() @Field age: number;
}
app.post('/users', [
body(UserDTO),
fail,
], (req, res, next) => {
// ...
});
Use afraid-swagger to create swagger documentation from afraid middlewares.
FAQs
Express middlewares for validating incoming data with type inference
The npm package afraid receives a total of 0 weekly downloads. As such, afraid popularity was classified as not popular.
We found that afraid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.