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

easy-formdata

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

easy-formdata

a module to parse formdata

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

easy-formdata

easy-formdata is a module to parse form data easily

Usage

const { expressParser, isFile } = require("easy-formdata");
const express = require("express");
const app = express();

app.use(expressParser());

app.post("/api", ({ body }, res) => {
  for(const key in body){
    if(isFile(body[key]))
      console.log(`${key} is ${body[key].size} bytes file`);
    else
      console.log(`${key} is a text field`);  
  }
  res.send(body);
})

app.listen(4000, () => console.log("server started"));

Types

expressParser

is the middleware that parsers the formdata for express

isFile

returns true if the argument passed is a File Object

File

an interface having this properties

  interface File {
    /** the file name */
    filename: string;
    /** the encoding of the file  */
    encoding: string;
    /** the mimetype of the file */
    mimetype: string;
    /** the size of the file */
    size: number;
    /** the data of the file */
    data: Buffer;
  }

FAQs

Package last updated on 15 Mar 2020

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