
Research
/Security News
10 npm Typosquatted Packages Deploy Multi-Stage Credential Harvester
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.
@zenweb/body
Advanced tools
请求内容解析
解析客户端发送的 JSON、Form-urlencoded、Text、二进制 等内容格式。
所支持的解析格式可扩展可自定义。默认支持格式:JSON、Form-urlencoded、Text
import { Context, mapping, Body, $body } from 'zenweb';
export class Controller {
@mapping({ path: '/', method: 'POST' })
post(body: Body) {
console.log(body.type); // POST body 内容类型
console.log(body.data); // POST Body 内容解析完成后的数据
}
@mapping({ path: '/', method: 'POST' })
async post() {
console.log(await getAge()); // 类型转换&校验
}
}
async function getAge() {
return (await $body.get({ age: '!int' })).age;
}
| 配置项 | 类型 | 默认值 | 功能 |
|---|---|---|---|
| encoding | string | 'utf-8' | 客户端未指定情况下,文本内容字符集的默认编码 |
| limit | number | 1024 * 1024 | 提交内容尺寸限制,默认:1MB |
| inflate | boolean | true | 是否支持 http 压缩传输的内容 |
| textTypes | string[] | ['text/*', 'json', '+json', 'xml', '+xml', 'urlencoded'] | 可以被解析成 Text 格式的 mimetype |
| parses | BodyParserClass[] | [JSONParser, URLEncodedParser] | 内容解析器 |
无
无
singleton
request
| 方法 | 功能 |
|---|---|
| getRawBody() | 取得当前请求原始请求内容 |
| getTextBody() | 取得当前请求文本内容,经过文字编码转换 |
| getObjectBody() | 取得当前请求数据对象 |
| $body | BodyHelper 对象快捷方式 |
FAQs
Zenweb Body module
The npm package @zenweb/body receives a total of 12 weekly downloads. As such, @zenweb/body popularity was classified as not popular.
We found that @zenweb/body 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.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.