New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

afraid

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afraid

Express middlewares for validating incoming data with type inference

  • 1.0.0-alpha.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

NPM Build Status

afraid

😧 Afraid?! You don't need to be: Incoming data of your express route is validated! Type inference included!

Installation

npm install afraid --save --no-optional

Usage

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) => {
    // ...
});

Using classes for validation and transformation

Installation

Omitting --no-optional will install required packages class-transformer and reflect-metadata automatically

npm install afraid --save 
Configuration

The following flags in tsconfig.json:

{
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true
}
Usage
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) => {
    // ...
});

Swagger documentation

Use afraid-swagger to create swagger documentation from afraid middlewares.

FAQs

Package last updated on 08 Jan 2019

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