Socket
Socket
Sign inDemoInstall

body-parsec

Package Overview
Dependencies
78
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 3.0.0

dist/chunk.RIRTAYR4.cjs

4

dist/index.d.ts

@@ -5,5 +5,5 @@ /// <reference types="node" />

declare type ReqWithBody = EventEmitter & Partial<IncomingMessage> & {
declare type ReqWithBody = IncomingMessage & {
body?: any;
};
} & EventEmitter;
declare const parsec: <T extends ReqWithBody>(fn: (body: any) => void) => (req: T | ReqWithBody, _res: ServerResponse) => Promise<void>;

@@ -10,0 +10,0 @@ declare const json: () => (req: ReqWithBody, _res?: ServerResponse, next?: () => void) => Promise<void>;

@@ -1,1 +0,1 @@

import{json,parsec,raw,text,urlencoded}from"./chunk.VMHT7XW4.js";export{parsec as custom,json,raw,text,urlencoded};
import{json,parsec,raw,text,urlencoded}from"./chunk.RIRTAYR4.js";export{parsec as custom,json,raw,text,urlencoded};

@@ -1,1 +0,1 @@

import{parsec}from"./chunk.VMHT7XW4.js";import{parse}from"querystring";const custom=(fn=body=>body)=>async(ctx,next)=>{await parsec(fn)(ctx.req,ctx.res);next==null?void 0:next()};const json=()=>async(ctx,next)=>{await custom(x=>JSON.parse(x.toString()))(ctx);next==null?void 0:next()};const raw=()=>async(ctx,next)=>{await custom(x=>x)(ctx);next==null?void 0:next()};const text=()=>async(ctx,next)=>{await custom(x=>x.toString())(ctx);next==null?void 0:next()};const urlencoded=()=>async(ctx,next)=>{await custom(x=>parse(x.toString()))(ctx);next==null?void 0:next()};export{custom,json,raw,text,urlencoded};
import{parsec}from"./chunk.RIRTAYR4.js";import{parse}from"querystring";const custom=(fn=body=>body)=>async(ctx,next)=>{await parsec(fn)(ctx.req,ctx.res);next==null?void 0:next()};const json=()=>async(ctx,next)=>{await custom(x=>JSON.parse(x.toString()))(ctx);next==null?void 0:next()};const raw=()=>async(ctx,next)=>{await custom(x=>x)(ctx);next==null?void 0:next()};const text=()=>async(ctx,next)=>{await custom(x=>x.toString())(ctx);next==null?void 0:next()};const urlencoded=()=>async(ctx,next)=>{await custom(x=>parse(x.toString()))(ctx);next==null?void 0:next()};export{custom,json,raw,text,urlencoded};
{
"name": "body-parsec",
"version": "2.1.0",
"version": "3.0.0",
"repository": "https://github.com/talentlessguy/parsec.git",

@@ -5,0 +5,0 @@ "author": "talentlessguy <pilll.PL22@gmail.com>",

@@ -93,5 +93,5 @@ # parsec 🌌

res.send(`
<urlencoded method="POST" action="/">
<form method="POST" action="/" enctype="application/x-www-form-urlencoded">
<input name="name" />
</urlencoded>
</form>
`)

@@ -98,0 +98,0 @@ })

import { ServerResponse as Response, IncomingMessage } from 'http'
import * as qs from 'querystring'
import { once, EventEmitter, on } from 'events'
import { once, EventEmitter } from 'events'
// Extend the request object with body
export type ReqWithBody = EventEmitter &
Partial<IncomingMessage> & {
body?: any
}
export type ReqWithBody = IncomingMessage & {
body?: any
} & EventEmitter

@@ -14,7 +13,9 @@ // Main function

if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(req.method)) {
const body = await once(req, 'data').then((data) => {
return fn(data)
})
let body = ''
req.body = body
for await (const chunk of req) {
body += chunk
}
req.body = fn(body)
}

@@ -21,0 +22,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc