Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Parses input in either application/json or application/x-www-form-urlencoded content-types, returning it as an object.

License

Notifications You must be signed in to change notification settings

tdmalone/simple-body-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Body Parser

Parses input in either application/json or application/x-www-form-urlencoded content-types, returning it as an object.

Usage

Install with Yarn:

yarn add @tdmalone/simple-body-parser

Or with npm:

npm install @tdmalone/simple-body-parser

Then, pass strings and get an object back:

const parse = require( '@tdmalone/simple-body-parser' );

const body = '{"some":"data"}';
const data = parse( body, 'application/json' );

console.log( data );

Ideally, you'd use this while parsing input from some source where the content-type is provided as a header.

Tests

Coming soon via Jest. Runnable with yarn test.

License

MIT.

About

Parses input in either application/json or application/x-www-form-urlencoded content-types, returning it as an object.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published