# connect-typed-body

> Connect middleware to convert parameter values to native types

Latest version **0.0.8** (published 2012-06-21) · 0 weekly downloads

## Install

```sh
npm install connect-typed-body
pnpm add connect-typed-body
yarn add connect-typed-body
bun add connect-typed-body
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2012-06-21 |
| First published | 2012-03-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.5.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Marc René Arns |
| Maintainers | metakeule |
| Keywords | web, middleware, connect |

## Links

- npm: https://www.npmjs.com/package/connect-typed-body
- Repository: https://github.com/metakeule/connect-typed-body
- npm.io page: https://npm.io/package/connect-typed-body

## Dependencies (1)

- [connect](https://npm.io/package/connect.md) >=2.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2012-06-21
- 0.0.7 — 2012-06-21
- 0.0.6 — 2012-06-21
- 0.0.5 — 2012-06-21
- 0.0.4 — 2012-05-24
- 0.0.3 — 2012-04-10
- 0.0.2 — 2012-03-18
- 0.0.1 — 2012-03-16

## README

connect-typed-body
===================

Connect middleware to convert parameter values to native types

[![Build Status](https://secure.travis-ci.org/metakeule/connect-typed-body.png)](https://secure.travis-ci.org/metakeule/connect-typed-body)

It relies on req.body parsed by connect.bodyParser.

    "3" -> 3
    "3.5" -> 3.5 # decimal point is localizable
    "3,545" -> 3545 # thousands seperator is localizable
    "false" -> false
    "true" -> true
    "null" -> null
    "undefined" -> undefined
    "" -> undefined

Usage
-------

Defaults (thousands_seperator = ',', decimal_point = '.')

    var connect = require('connect');
    var typedBody = require('connect-typed-body');
    var app = connect();
    app.use(connect.bodyParser);  // important must come before typedBody
    app.use(typedBody());
    app.use( function(req, res){
      res.end JSON.stringify(req.body)
    }); 

Localized

    var connect = require('connect');
    var typedBody = require('connect-typed-body');
    var app = connect();
    app.use(connect.bodyParser);  // important must come before typedBody
    app.use(typedBody({thousands_seperator: '.', decimal_point: ','}));
    app.use( function(req, res){
      res.end JSON.stringify(req.body)
    }); 

Dynamic overwrite

    var connect = require('connect');
    var typedBody = require('connect-typed-body');
    var app = connect();
    app.use(connect.bodyParser);  // important must come before typedBody
    app.use( function(req, res,next){
      if(req.locale == "de_DE"){
        req.decimal_point = ',' ;
        req.thousands_seperator = '.';
      }
      next(); 
    });
    app.use(typedBody());
    app.use( function(req, res){
      res.end JSON.stringify(req.body)
    }); 

Copyright
----------

Copyright (c) 2012 Marc Rene Arns. See LICENSE.txt for
further details.

---
_Source: https://npm.io/package/connect-typed-body · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
