connect-typed-body

Connect middleware to convert parameter values to native types

npm install connect-typed-body
8 downloads in the last week
8 downloads in the last month

connect-typed-body

Connect middleware to convert parameter values to native types

Build Status

It uses 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(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(typedBody({thousands_seperator: '.', decimal_point: ','}));
app.use( function(req, res){
  res.end JSON.stringify(req.body)
}); 

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

npm loves you