🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@zenweb/body

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenweb/body

Zenweb Body module

npmnpm
Version
3.4.0
Version published
Weekly downloads
169
-61.59%
Maintainers
1
Weekly downloads
 
Created
Source

ZenWeb Body module

ZenWeb

支持 JSON、Form 等内容格式的基础解析模块

演示

import { Context, mapping, Body, BodyHelper } 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' })
  post(body: BodyHelper) {
    console.log(body.get({ age: '!int' })); // 类型转换&校验
  }
}

内置的对象内容解析器

  • json
  • x-www-form-urlencoded

配置项

类型默认值说明
encodingstring'utf-8'在未能匹配到 header 信息时,默认text内容编码格式
limitnumber1MB内容大小限制
inflatebooleantrue是否支持压缩内容解压
textTypesstring[]['text/*', 'json', '+json', 'xml', '+xml', 'urlencoded']支持解析为文本的类型
parsesBodyParserClass[][JSONParser, URLEncodedParser]对象解析器

其他扩展格式解析

xml

Keywords

web

FAQs

Package last updated on 17 Mar 2023

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