Skip to content

Parse query strings and form-urlencoded bodies for Zeit's Micro

License

Unlicense, Unlicense licenses found

Licenses found

Unlicense
LICENSE
Unlicense
UNLICENSE
Notifications You must be signed in to change notification settings

randallsquared/micro-urlencoded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

query and urlencoded parsing for micro

Parse query strings and form-urlencoded bodies for Zeit's Micro.

Install

yarn add micro-urlencoded
# or
npm install --save micro-urlencoded

Usage

The first argument to micro-urlencoded may be a string, Node Buffer, an async handler function, or an IncomingMessage object (or similar enough to one for micro.buffer()).

const query = require('micro-urlencoded');

string

module.exports = async (req, res) {
  const url = 'https://example.com/whatever?query=starts&here=2';
  const queryString = require('url').parse(url);
  const queryObject = query(queryString);

};

Buffer

module.exports = async (req, res) {
  const buffer = micro.buffer(req);
  // do other things with the request body buffer...

  // if the buffer is url-encoded
  const body = query(buffer);

};

IncomingMessage

module.exports = async (req, res) {
  const {query, body} = query(req);

};

function

const handler = async (req, res) => {
  //  your handler code
};

module.exports = query(handler);

License

The Unlicense, which is to say, public domain unless a license is required in your jurisdiction, in which case please follow the LICENSE file.

About

Parse query strings and form-urlencoded bodies for Zeit's Micro

Resources

License

Unlicense, Unlicense licenses found

Licenses found

Unlicense
LICENSE
Unlicense
UNLICENSE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published